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 "FormTabular.h"
14 #include "ControlTabular.h"
15 #include "forms/form_tabular.h"
17 #include "xforms_helpers.h"
20 #include "controllers/ButtonController.h"
21 #include "controllers/helper_funcs.h"
23 #include "support/lstrings.h"
25 #include "lyx_forms.h"
27 #include <boost/bind.hpp>
36 using support::contains;
37 using support::getStringFromVector;
38 using support::isStrDbl;
44 #if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL < 2)
45 bool const scalableTabfolders = false;
47 bool const scalableTabfolders = true;
53 typedef FormController<ControlTabular, FormView<FD_tabular> > base_class;
55 FormTabular::FormTabular(Dialog & parent)
56 : base_class(parent, _("Table Settings"), scalableTabfolders),
57 closing_(false), actCell_(-1)
62 void FormTabular::redraw()
64 if (form() && form()->visible)
65 fl_redraw_form(form());
69 FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder);
70 if (outer_form && outer_form->visible)
71 fl_redraw_form(outer_form);
75 void FormTabular::build()
77 dialog_.reset(build_tabular(this));
79 // Allow the base class to control messages
80 setMessageWidget(dialog_->text_warning);
82 // trigger an input event for cut&paste with middle mouse button.
83 setPrehandler(dialog_->input_tabular_column);
84 setPrehandler(dialog_->input_tabular_row);
86 // Create the contents of the unit choices; don't include the "%" terms.
87 vector<string> units_vec = getLatexUnits();
88 vector<string>::iterator ret =
89 remove_if(units_vec.begin(), units_vec.end(),
90 bind(contains<char>, _1, '%'));
91 units_vec.erase(ret, units_vec.end());
92 string const units = getStringFromVector(units_vec, "|");
94 // tabular options form
95 tabular_options_.reset(build_tabular_options(this));
97 // column options form
98 column_options_.reset(build_tabular_column(this));
100 fl_set_input_return(column_options_->input_column_width,
102 fl_set_input_return(column_options_->input_special_alignment,
105 // trigger an input event for cut&paste with middle mouse button.
106 setPrehandler(column_options_->input_column_width);
107 setPrehandler(column_options_->input_special_alignment);
109 fl_addto_choice(column_options_->choice_value_column_width,
113 cell_options_.reset(build_tabular_cell(this));
115 fl_set_input_return(cell_options_->input_mcolumn_width,
117 fl_set_input_return(cell_options_->input_special_multialign,
120 // trigger an input event for cut&paste with middle mouse button.
121 setPrehandler(cell_options_->input_mcolumn_width);
122 setPrehandler(cell_options_->input_special_multialign);
124 fl_addto_choice(cell_options_->choice_value_mcolumn_width,
127 longtable_options_.reset(build_tabular_longtable(this));
129 // Enable the tabfolder to be rescaled correctly.
130 if (scalableTabfolders)
131 fl_set_tabfolder_autofit(dialog_->tabfolder, FL_FIT);
134 fl_addto_tabfolder(dialog_->tabfolder, _("Table").c_str(),
135 tabular_options_->form);
136 fl_addto_tabfolder(dialog_->tabfolder, _("Column/Row").c_str(),
137 column_options_->form);
138 fl_addto_tabfolder(dialog_->tabfolder, _("Cell").c_str(),
139 cell_options_->form);
140 fl_addto_tabfolder(dialog_->tabfolder, _("LongTable").c_str(),
141 longtable_options_->form);
143 // FIXME: addReadOnly everything
147 void FormTabular::update()
152 LyXTabular const & tabular = controller().tabular();
159 int const cell = controller().getActiveCell();
161 int column = tabular.column_of_cell(cell) + 1;
163 fl_activate_object(column_options_->input_special_alignment);
164 fl_activate_object(cell_options_->input_special_multialign);
165 fl_activate_object(column_options_->input_column_width);
166 fl_activate_object(column_options_->choice_value_column_width);
167 sprintf(buf, "%d", column);
168 fl_set_input(dialog_->input_tabular_column, buf);
169 fl_deactivate_object(dialog_->input_tabular_column);
170 int row = tabular.row_of_cell(cell);
171 sprintf(buf, "%d", row + 1);
172 fl_set_input(dialog_->input_tabular_row, buf);
173 fl_deactivate_object(dialog_->input_tabular_row);
174 if (tabular.isMultiColumn(cell)) {
175 fl_set_button(cell_options_->check_multicolumn, 1);
176 fl_set_button(cell_options_->check_border_top,
177 tabular.topLine(cell)?1:0);
178 setEnabled(cell_options_->check_border_top, true);
179 fl_set_button(cell_options_->check_border_bottom,
180 tabular.bottomLine(cell)?1:0);
181 setEnabled(cell_options_->check_border_bottom, true);
182 // pay attention to left/right lines they are only allowed
183 // to set if we are in first/last cell of row or if the left/right
184 // cell is also a multicolumn.
185 if (tabular.isFirstCellInRow(cell) ||
186 tabular.isMultiColumn(cell-1)) {
187 fl_set_button(cell_options_->check_border_left,
188 tabular.leftLine(cell)?1:0);
189 setEnabled(cell_options_->check_border_left, true);
191 fl_set_button(cell_options_->check_border_left, 0);
192 setEnabled(cell_options_->check_border_left, false);
194 if (tabular.isLastCellInRow(cell) ||
195 tabular.isMultiColumn(cell+1)) {
196 fl_set_button(cell_options_->check_border_right,
197 tabular.rightLine(cell)?1:0);
198 setEnabled(cell_options_->check_border_right, true);
200 fl_set_button(cell_options_->check_border_right, 0);
201 setEnabled(cell_options_->check_border_right, false);
203 pwidth = tabular.getMColumnPWidth(cell);
204 align = tabular.getAlignment(cell);
205 // set the horiz. alignment, default is left here
206 fl_set_button(cell_options_->radio_align_left, 0);
207 fl_set_button(cell_options_->radio_align_right, 0);
208 fl_set_button(cell_options_->radio_align_center, 0);
209 if (align == LYX_ALIGN_RIGHT)
210 fl_set_button(cell_options_->radio_align_right, 1);
211 else if (align == LYX_ALIGN_CENTER)
212 fl_set_button(cell_options_->radio_align_center, 1);
214 fl_set_button(cell_options_->radio_align_left, 1);
216 align = tabular.getVAlignment(cell);
217 fl_set_button(cell_options_->radio_valign_top, 0);
218 fl_set_button(cell_options_->radio_valign_bottom, 0);
219 fl_set_button(cell_options_->radio_valign_middle, 0);
220 if (pwidth.zero() || (align == LyXTabular::LYX_VALIGN_MIDDLE))
221 fl_set_button(cell_options_->radio_valign_middle, 1);
222 else if (align == LyXTabular::LYX_VALIGN_BOTTOM)
223 fl_set_button(cell_options_->radio_valign_bottom, 1);
225 fl_set_button(cell_options_->radio_valign_top, 1);
227 special = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
228 fl_set_input(cell_options_->input_special_multialign, special.c_str());
229 bool const metric(controller().useMetricUnits());
230 string const default_unit = metric ? "cm" : "in";
231 updateWidgetsFromLength(cell_options_->input_mcolumn_width,
232 cell_options_->choice_value_mcolumn_width,
233 pwidth, default_unit);
235 if (!bc().bp().isReadOnly()) {
236 setEnabled(cell_options_->input_special_multialign, true);
237 setEnabled(cell_options_->input_mcolumn_width, true);
238 setEnabled(cell_options_->choice_value_mcolumn_width, true);
241 setEnabled(cell_options_->radio_valign_top, !pwidth.zero());
242 setEnabled(cell_options_->radio_valign_bottom, !pwidth.zero());
243 setEnabled(cell_options_->radio_valign_middle, !pwidth.zero());
245 setEnabled(cell_options_->radio_align_left, true);
246 setEnabled(cell_options_->radio_align_right, true);
247 setEnabled(cell_options_->radio_align_center, true);
249 fl_set_button(cell_options_->check_multicolumn, 0);
251 fl_set_button(cell_options_->check_border_top, 0);
252 setEnabled(cell_options_->check_border_top, false);
254 fl_set_button(cell_options_->check_border_bottom, 0);
255 setEnabled(cell_options_->check_border_bottom, false);
257 fl_set_button(cell_options_->check_border_left, 0);
258 setEnabled(cell_options_->check_border_left, false);
260 fl_set_button(cell_options_->check_border_right, 0);
261 setEnabled(cell_options_->check_border_right, false);
263 fl_set_button(cell_options_->radio_align_left, 0);
264 setEnabled(cell_options_->radio_align_left, false);
266 fl_set_button(cell_options_->radio_align_right, 0);
267 setEnabled(cell_options_->radio_align_right, false);
269 fl_set_button(cell_options_->radio_align_center, 0);
270 setEnabled(cell_options_->radio_align_center, false);
272 fl_set_button(cell_options_->radio_valign_top, 0);
273 setEnabled(cell_options_->radio_valign_top, false);
275 fl_set_button(cell_options_->radio_valign_bottom, 0);
276 setEnabled(cell_options_->radio_valign_bottom, false);
278 fl_set_button(cell_options_->radio_valign_middle, 0);
279 setEnabled(cell_options_->radio_valign_middle, false);
281 fl_set_input(cell_options_->input_special_multialign, "");
282 setEnabled(cell_options_->input_special_multialign, false);
284 fl_set_input(cell_options_->input_mcolumn_width, "");
285 setEnabled(cell_options_->input_mcolumn_width, false);
286 setEnabled(cell_options_->choice_value_mcolumn_width, false);
288 if (tabular.getRotateCell(cell))
289 fl_set_button(cell_options_->check_rotate_cell, 1);
291 fl_set_button(cell_options_->check_rotate_cell, 0);
292 if (tabular.topLine(cell, true))
293 fl_set_button(column_options_->check_border_top, 1);
295 fl_set_button(column_options_->check_border_top, 0);
296 if (tabular.bottomLine(cell, true))
297 fl_set_button(column_options_->check_border_bottom, 1);
299 fl_set_button(column_options_->check_border_bottom, 0);
300 if (tabular.leftLine(cell, true))
301 fl_set_button(column_options_->check_border_left, 1);
303 fl_set_button(column_options_->check_border_left, 0);
304 if (tabular.rightLine(cell, true))
305 fl_set_button(column_options_->check_border_right, 1);
307 fl_set_button(column_options_->check_border_right, 0);
308 special = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
309 fl_set_input(column_options_->input_special_alignment, special.c_str());
311 bool const isReadonly = bc().bp().isReadOnly();
312 setEnabled(column_options_->input_special_alignment, !isReadonly);
314 pwidth = tabular.getColumnPWidth(cell);
315 bool const metric = controller().useMetricUnits();
316 string const default_unit = metric ? "cm" : "in";
317 updateWidgetsFromLength(column_options_->input_column_width,
318 column_options_->choice_value_column_width,
319 pwidth, default_unit);
320 setEnabled(column_options_->input_column_width, !isReadonly);
321 setEnabled(column_options_->choice_value_column_width, !isReadonly);
323 setEnabled(cell_options_->check_useminipage, !pwidth.zero());
324 if (!pwidth.zero()) {
325 if (tabular.getUsebox(cell) == 2)
326 fl_set_button(cell_options_->check_useminipage, 1);
328 fl_set_button(cell_options_->check_useminipage, 0);
330 fl_set_button(cell_options_->check_useminipage, 0);
332 align = tabular.getAlignment(cell, true);
333 fl_set_button(column_options_->radio_align_left, 0);
334 fl_set_button(column_options_->radio_align_right, 0);
335 fl_set_button(column_options_->radio_align_center, 0);
336 fl_set_button(column_options_->radio_align_block, 0);
337 if (align == LYX_ALIGN_LEFT)
338 fl_set_button(column_options_->radio_align_left, 1);
339 else if (align == LYX_ALIGN_RIGHT)
340 fl_set_button(column_options_->radio_align_right, 1);
341 else if (align == LYX_ALIGN_CENTER)
342 fl_set_button(column_options_->radio_align_center, 1);
344 fl_set_button(column_options_->radio_align_block, 1);
345 align = tabular.getVAlignment(cell, true);
346 fl_set_button(column_options_->radio_valign_top, 0);
347 fl_set_button(column_options_->radio_valign_bottom, 0);
348 fl_set_button(column_options_->radio_valign_middle, 0);
349 if (pwidth.zero() || (align == LyXTabular::LYX_VALIGN_MIDDLE))
350 fl_set_button(column_options_->radio_valign_middle, 1);
351 else if (align == LyXTabular::LYX_VALIGN_BOTTOM)
352 fl_set_button(column_options_->radio_valign_bottom, 1);
354 fl_set_button(column_options_->radio_valign_top, 1);
356 setEnabled(column_options_->radio_align_left, true);
357 setEnabled(column_options_->radio_align_right, true);
358 setEnabled(column_options_->radio_align_center, true);
359 setEnabled(column_options_->radio_align_block, !pwidth.zero());
360 setEnabled(column_options_->radio_valign_top, !pwidth.zero());
361 setEnabled(column_options_->radio_valign_bottom, !pwidth.zero());
362 setEnabled(column_options_->radio_valign_middle, !pwidth.zero());
364 fl_set_button(tabular_options_->check_longtable,
365 tabular.isLongTabular());
367 bool const enable = tabular.isLongTabular();
369 setEnabled(longtable_options_->check_lt_firsthead, enable);
370 setEnabled(longtable_options_->check_1head_2border_above, enable);
371 setEnabled(longtable_options_->check_1head_2border_below, enable);
372 setEnabled(longtable_options_->check_1head_empty, enable);
373 setEnabled(longtable_options_->check_lt_head, enable);
374 setEnabled(longtable_options_->check_head_2border_above, enable);
375 setEnabled(longtable_options_->check_head_2border_below, enable);
376 setEnabled(longtable_options_->check_lt_foot, enable);
377 setEnabled(longtable_options_->check_foot_2border_above, enable);
378 setEnabled(longtable_options_->check_foot_2border_below, enable);
379 setEnabled(longtable_options_->check_lt_lastfoot, enable);
380 setEnabled(longtable_options_->check_lastfoot_2border_above, enable);
381 setEnabled(longtable_options_->check_lastfoot_2border_below, enable);
382 setEnabled(longtable_options_->check_lastfoot_empty, enable);
383 setEnabled(longtable_options_->check_lt_newpage, enable);
386 LyXTabular::ltType ltt;
388 bool row_set = tabular.getRowOfLTHead(row, ltt);
389 fl_set_button(longtable_options_->check_lt_head, row_set);
391 fl_set_button(longtable_options_->check_head_2border_above,
393 fl_set_button(longtable_options_->check_head_2border_below,
397 setEnabled(longtable_options_->check_head_2border_above, 0);
398 setEnabled(longtable_options_->check_head_2border_below, 0);
399 fl_set_button(longtable_options_->check_head_2border_above,0);
400 fl_set_button(longtable_options_->check_head_2border_below,0);
401 fl_set_button(longtable_options_->check_1head_empty,0);
402 setEnabled(longtable_options_->check_1head_empty, 0);
406 row_set = tabular.getRowOfLTFirstHead(row, ltt);
407 fl_set_button(longtable_options_->check_lt_firsthead, row_set);
408 if (ltt.set && (!ltt.empty || !use_empty)) {
409 fl_set_button(longtable_options_->check_1head_2border_above,
411 fl_set_button(longtable_options_->check_1head_2border_below,
414 setEnabled(longtable_options_->check_1head_2border_above, 0);
415 setEnabled(longtable_options_->check_1head_2border_below, 0);
416 fl_set_button(longtable_options_->check_1head_2border_above,0);
417 fl_set_button(longtable_options_->check_1head_2border_below,0);
419 fl_set_button(longtable_options_->check_1head_empty,ltt.empty);
421 setEnabled(longtable_options_->check_lt_firsthead, 0);
425 row_set = tabular.getRowOfLTFoot(row, ltt);
426 fl_set_button(longtable_options_->check_lt_foot, row_set);
428 fl_set_button(longtable_options_->check_foot_2border_above,
430 fl_set_button(longtable_options_->check_foot_2border_below,
434 setEnabled(longtable_options_->check_foot_2border_above, 0);
435 setEnabled(longtable_options_->check_foot_2border_below, 0);
436 fl_set_button(longtable_options_->check_foot_2border_above,0);
437 fl_set_button(longtable_options_->check_foot_2border_below,0);
438 fl_set_button(longtable_options_->check_lastfoot_empty, 0);
439 setEnabled(longtable_options_->check_lastfoot_empty, 0);
443 row_set = tabular.getRowOfLTLastFoot(row, ltt);
444 fl_set_button(longtable_options_->check_lt_lastfoot, row_set);
445 if (ltt.set && (!ltt.empty || !use_empty)) {
446 fl_set_button(longtable_options_->check_lastfoot_2border_above,
448 fl_set_button(longtable_options_->check_lastfoot_2border_below,
451 setEnabled(longtable_options_->check_lastfoot_2border_above,0);
452 setEnabled(longtable_options_->check_lastfoot_2border_below,0);
453 fl_set_button(longtable_options_->check_lastfoot_2border_above, 0);
454 fl_set_button(longtable_options_->check_lastfoot_2border_below, 0);
456 fl_set_button(longtable_options_->check_lastfoot_empty,
459 setEnabled(longtable_options_->check_lt_lastfoot, 0);
462 fl_set_button(longtable_options_->check_lt_newpage,
463 tabular.getLTNewPage(row));
465 fl_set_button(longtable_options_->check_lt_firsthead, 0);
466 fl_set_button(longtable_options_->check_1head_2border_above, 0);
467 fl_set_button(longtable_options_->check_1head_2border_below, 0);
468 fl_set_button(longtable_options_->check_1head_empty, 0);
469 fl_set_button(longtable_options_->check_lt_head, 0);
470 fl_set_button(longtable_options_->check_head_2border_above, 0);
471 fl_set_button(longtable_options_->check_head_2border_below, 0);
472 fl_set_button(longtable_options_->check_lt_foot, 0);
473 fl_set_button(longtable_options_->check_foot_2border_above, 0);
474 fl_set_button(longtable_options_->check_foot_2border_below, 0);
475 fl_set_button(longtable_options_->check_lt_lastfoot, 0);
476 fl_set_button(longtable_options_->check_lastfoot_2border_above, 0);
477 fl_set_button(longtable_options_->check_lastfoot_2border_below, 0);
478 fl_set_button(longtable_options_->check_lastfoot_empty, 0);
479 fl_set_button(longtable_options_->check_lt_newpage, 0);
481 fl_set_button(tabular_options_->check_rotate_tabular,
482 tabular.getRotateTabular());
486 ButtonPolicy::SMInput FormTabular::input(FL_OBJECT * ob, long)
489 LyXTabular::Feature num = LyXTabular::LAST_ACTION;
492 LyXTabular const & tabular = controller().tabular();
494 int const cell = controller().getActiveCell();
496 // ugly hack to auto-apply the stuff that hasn't been
497 // yet. don't let this continue to exist ...
498 if (ob == dialog_->button_close) {
501 getLengthFromWidgets(column_options_->input_column_width,
502 column_options_->choice_value_column_width);
504 LyXLength llen = tabular.getColumnPWidth(cell);
506 w2 = llen.asString();
508 string mw1 = getLengthFromWidgets(cell_options_->input_mcolumn_width,
509 cell_options_->choice_value_mcolumn_width);
510 llen = tabular.getMColumnPWidth(cell);
515 mw2 = llen.asString();
517 string al1 = getString(column_options_->input_special_alignment);
518 string al2 = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
519 string mal1 = getString(cell_options_->input_special_multialign);
520 string mal2 = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
522 // we must do these all at the end
524 input(column_options_->input_column_width, 0);
526 input(cell_options_->input_mcolumn_width, 0);
528 input(column_options_->input_special_alignment, 0);
530 input(cell_options_->input_special_multialign, 0);
533 return ButtonPolicy::SMI_VALID;
536 if (actCell_ != cell) {
538 postWarning(_("Wrong Cursor position, updated window"));
539 return ButtonPolicy::SMI_VALID;
542 // No point in processing directives that you can't do anything with
543 // anyhow, so exit now if the buffer is read-only.
544 if (bc().bp().isReadOnly()) {
546 return ButtonPolicy::SMI_VALID;
549 if ((ob == column_options_->input_column_width) ||
550 (ob == column_options_->choice_value_column_width)) {
552 getLengthFromWidgets(column_options_->input_column_width,
553 column_options_->choice_value_column_width);
554 controller().set(LyXTabular::SET_PWIDTH, str);
556 //check if the input is valid
557 string const input = getString(column_options_->input_column_width);
558 if (!input.empty() && !isValidLength(input) && !isStrDbl(input)) {
559 postWarning(_("Invalid Length (valid example: 10mm)"));
560 return ButtonPolicy::SMI_INVALID;
563 update(); // update for alignment
564 return ButtonPolicy::SMI_VALID;
567 if ((ob == cell_options_->input_mcolumn_width) ||
568 (ob == cell_options_->choice_value_mcolumn_width)) {
570 getLengthFromWidgets(cell_options_->input_mcolumn_width,
571 cell_options_->choice_value_mcolumn_width);
572 controller().set(LyXTabular::SET_MPWIDTH, str);
574 //check if the input is valid
575 string const input = getString(cell_options_->input_mcolumn_width);
576 if (!input.empty() && !isValidLength(input) && !isStrDbl(input)) {
577 postWarning(_("Invalid Length (valid example: 10mm)"));
578 return ButtonPolicy::SMI_INVALID;
580 update(); // update for alignment
581 return ButtonPolicy::SMI_VALID;
584 if (ob == tabular_options_->button_append_row)
585 num = LyXTabular::APPEND_ROW;
586 else if (ob == tabular_options_->button_append_column)
587 num = LyXTabular::APPEND_COLUMN;
588 else if (ob == tabular_options_->button_delete_row)
589 num = LyXTabular::DELETE_ROW;
590 else if (ob == tabular_options_->button_delete_column)
591 num = LyXTabular::DELETE_COLUMN;
592 else if (ob == tabular_options_->button_set_borders)
593 num = LyXTabular::SET_ALL_LINES;
594 else if (ob == tabular_options_->button_unset_borders)
595 num = LyXTabular::UNSET_ALL_LINES;
596 else if (ob == column_options_->check_border_top)
597 num = LyXTabular::TOGGLE_LINE_TOP;
598 else if (ob == column_options_->check_border_bottom)
599 num = LyXTabular::TOGGLE_LINE_BOTTOM;
600 else if (ob == column_options_->check_border_left)
601 num = LyXTabular::TOGGLE_LINE_LEFT;
602 else if (ob == column_options_->check_border_right)
603 num = LyXTabular::TOGGLE_LINE_RIGHT;
604 else if (ob == column_options_->radio_align_left)
605 num = LyXTabular::ALIGN_LEFT;
606 else if (ob == column_options_->radio_align_right)
607 num = LyXTabular::ALIGN_RIGHT;
608 else if (ob == column_options_->radio_align_center)
609 num = LyXTabular::ALIGN_CENTER;
610 else if (ob == column_options_->radio_align_block)
611 num = LyXTabular::ALIGN_BLOCK;
612 else if (ob == column_options_->radio_valign_top)
613 num = LyXTabular::VALIGN_TOP;
614 else if (ob == column_options_->radio_valign_bottom)
615 num = LyXTabular::VALIGN_BOTTOM;
616 else if (ob == column_options_->radio_valign_middle)
617 num = LyXTabular::VALIGN_MIDDLE;
618 else if (ob == cell_options_->check_multicolumn)
619 num = LyXTabular::MULTICOLUMN;
620 else if (ob == tabular_options_->check_longtable) {
621 if (fl_get_button(tabular_options_->check_longtable))
622 num = LyXTabular::SET_LONGTABULAR;
624 num = LyXTabular::UNSET_LONGTABULAR;
625 } else if (ob == tabular_options_->check_rotate_tabular) {
626 s = fl_get_button(tabular_options_->check_rotate_tabular);
628 num = LyXTabular::SET_ROTATE_TABULAR;
630 num = LyXTabular::UNSET_ROTATE_TABULAR;
631 } else if (ob == cell_options_->check_rotate_cell) {
632 s = fl_get_button(cell_options_->check_rotate_cell);
634 num = LyXTabular::SET_ROTATE_CELL;
636 num = LyXTabular::UNSET_ROTATE_CELL;
637 } else if (ob == cell_options_->check_useminipage) {
638 num = LyXTabular::SET_USEBOX;
640 } else if ((ob == longtable_options_->check_lt_firsthead) ||
641 (ob == longtable_options_->check_1head_2border_above) ||
642 (ob == longtable_options_->check_1head_2border_below) ||
643 (ob == longtable_options_->check_1head_empty) ||
644 (ob == longtable_options_->check_lt_head) ||
645 (ob == longtable_options_->check_head_2border_above) ||
646 (ob == longtable_options_->check_head_2border_below) ||
647 (ob == longtable_options_->check_lt_foot) ||
648 (ob == longtable_options_->check_foot_2border_above) ||
649 (ob == longtable_options_->check_foot_2border_below) ||
650 (ob == longtable_options_->check_lt_lastfoot) ||
651 (ob == longtable_options_->check_lastfoot_2border_above) ||
652 (ob == longtable_options_->check_lastfoot_2border_below) ||
653 (ob == longtable_options_->check_lastfoot_empty)) {
654 num = static_cast<LyXTabular::Feature>(checkLongtableOptions(ob, special));
655 } else if (ob == longtable_options_->check_lt_newpage) {
656 num = LyXTabular::SET_LTNEWPAGE;
657 } else if (ob == column_options_->input_special_alignment) {
658 special = getString(column_options_->input_special_alignment);
659 num = LyXTabular::SET_SPECIAL_COLUMN;
660 } else if (ob == cell_options_->input_special_multialign) {
661 special = getString(cell_options_->input_special_multialign);
662 num = LyXTabular::SET_SPECIAL_MULTI;
663 } else if (ob == cell_options_->check_border_top)
664 num = LyXTabular::M_TOGGLE_LINE_TOP;
665 else if (ob == cell_options_->check_border_bottom)
666 num = LyXTabular::M_TOGGLE_LINE_BOTTOM;
667 else if (ob == cell_options_->check_border_left)
668 num = LyXTabular::M_TOGGLE_LINE_LEFT;
669 else if (ob == cell_options_->check_border_right)
670 num = LyXTabular::M_TOGGLE_LINE_RIGHT;
671 else if (ob == cell_options_->radio_align_left)
672 num = LyXTabular::M_ALIGN_LEFT;
673 else if (ob == cell_options_->radio_align_right)
674 num = LyXTabular::M_ALIGN_RIGHT;
675 else if (ob == cell_options_->radio_align_center)
676 num = LyXTabular::M_ALIGN_CENTER;
677 else if (ob == cell_options_->radio_valign_top)
678 num = LyXTabular::M_VALIGN_TOP;
679 else if (ob == cell_options_->radio_valign_bottom)
680 num = LyXTabular::M_VALIGN_BOTTOM;
681 else if (ob == cell_options_->radio_valign_middle)
682 num = LyXTabular::M_VALIGN_MIDDLE;
684 return ButtonPolicy::SMI_VALID;
686 controller().set(num, special);
689 return ButtonPolicy::SMI_VALID;
693 int FormTabular::checkLongtableOptions(FL_OBJECT * ob, string & special)
695 bool flag = fl_get_button(ob);
696 if ((ob == longtable_options_->check_1head_2border_above) ||
697 (ob == longtable_options_->check_head_2border_above) ||
698 (ob == longtable_options_->check_foot_2border_above) ||
699 (ob == longtable_options_->check_lastfoot_2border_above)) {
700 special = "dl_above";
701 } else if ((ob == longtable_options_->check_1head_2border_below) ||
702 (ob == longtable_options_->check_head_2border_below) ||
703 (ob == longtable_options_->check_foot_2border_below) ||
704 (ob == longtable_options_->check_lastfoot_2border_below)) {
705 special = "dl_below";
706 } else if ((ob == longtable_options_->check_1head_empty) ||
707 (ob == longtable_options_->check_lastfoot_empty)) {
712 if ((ob == longtable_options_->check_lt_firsthead) ||
713 (ob == longtable_options_->check_1head_2border_above) ||
714 (ob == longtable_options_->check_1head_2border_below) ||
715 (ob == longtable_options_->check_1head_empty)) {
716 return (flag ? LyXTabular::SET_LTFIRSTHEAD :
717 LyXTabular::UNSET_LTFIRSTHEAD);
718 } else if ((ob == longtable_options_->check_lt_head) ||
719 (ob == longtable_options_->check_head_2border_above) ||
720 (ob == longtable_options_->check_head_2border_below)) {
721 return (flag ? LyXTabular::SET_LTHEAD : LyXTabular::UNSET_LTHEAD);
722 } else if ((ob == longtable_options_->check_lt_foot) ||
723 (ob == longtable_options_->check_foot_2border_above) ||
724 (ob == longtable_options_->check_foot_2border_below)) {
725 return (flag ? LyXTabular::SET_LTFOOT : LyXTabular::UNSET_LTFOOT);
726 } else if ((ob == longtable_options_->check_lt_lastfoot) ||
727 (ob == longtable_options_->check_lastfoot_2border_above) ||
728 (ob == longtable_options_->check_lastfoot_2border_below) ||
729 (ob == longtable_options_->check_lastfoot_empty)) {
730 return (flag ? LyXTabular::SET_LTLASTFOOT :
731 LyXTabular::UNSET_LTLASTFOOT);
734 return LyXTabular::LAST_ACTION;
737 } // namespace frontend