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 using namespace lyx::support;
35 #if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL < 2)
36 bool const scalableTabfolders = false;
38 bool const scalableTabfolders = true;
44 typedef FormController<ControlTabular, FormView<FD_tabular> > base_class;
46 FormTabular::FormTabular(Dialog & parent)
47 : base_class(parent, _("Table Settings"), scalableTabfolders),
48 closing_(false), actCell_(-1)
53 void FormTabular::redraw()
55 if (form() && form()->visible)
56 fl_redraw_form(form());
60 FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder);
61 if (outer_form && outer_form->visible)
62 fl_redraw_form(outer_form);
66 void FormTabular::build()
68 dialog_.reset(build_tabular(this));
70 // Allow the base class to control messages
71 setMessageWidget(dialog_->text_warning);
73 // trigger an input event for cut&paste with middle mouse button.
74 setPrehandler(dialog_->input_tabular_column);
75 setPrehandler(dialog_->input_tabular_row);
77 // Create the contents of the unit choices; don't include the "%" terms.
78 vector<string> units_vec = getLatexUnits();
79 vector<string>::iterator ret =
80 remove_if(units_vec.begin(), units_vec.end(),
81 bind2nd(contains_functor(), "%"));
82 units_vec.erase(ret, units_vec.end());
83 string const units = getStringFromVector(units_vec, "|");
85 // tabular options form
86 tabular_options_.reset(build_tabular_options(this));
88 // column options form
89 column_options_.reset(build_tabular_column(this));
91 fl_set_input_return(column_options_->input_column_width,
93 fl_set_input_return(column_options_->input_special_alignment,
96 // trigger an input event for cut&paste with middle mouse button.
97 setPrehandler(column_options_->input_column_width);
98 setPrehandler(column_options_->input_special_alignment);
100 fl_addto_choice(column_options_->choice_value_column_width,
104 cell_options_.reset(build_tabular_cell(this));
106 fl_set_input_return(cell_options_->input_mcolumn_width,
108 fl_set_input_return(cell_options_->input_special_multialign,
111 // trigger an input event for cut&paste with middle mouse button.
112 setPrehandler(cell_options_->input_mcolumn_width);
113 setPrehandler(cell_options_->input_special_multialign);
115 fl_addto_choice(cell_options_->choice_value_mcolumn_width,
118 longtable_options_.reset(build_tabular_longtable(this));
120 // Enable the tabfolder to be rescaled correctly.
121 if (scalableTabfolders)
122 fl_set_tabfolder_autofit(dialog_->tabfolder, FL_FIT);
125 fl_addto_tabfolder(dialog_->tabfolder, _("Table").c_str(),
126 tabular_options_->form);
127 fl_addto_tabfolder(dialog_->tabfolder, _("Column/Row").c_str(),
128 column_options_->form);
129 fl_addto_tabfolder(dialog_->tabfolder, _("Cell").c_str(),
130 cell_options_->form);
131 fl_addto_tabfolder(dialog_->tabfolder, _("LongTable").c_str(),
132 longtable_options_->form);
134 // FIXME: addReadOnly everything
138 void FormTabular::update()
143 LyXTabular const & tabular = controller().tabular();
150 int const cell = controller().getActiveCell();
152 int column = tabular.column_of_cell(cell) + 1;
154 fl_activate_object(column_options_->input_special_alignment);
155 fl_activate_object(cell_options_->input_special_multialign);
156 fl_activate_object(column_options_->input_column_width);
157 fl_activate_object(column_options_->choice_value_column_width);
158 sprintf(buf, "%d", column);
159 fl_set_input(dialog_->input_tabular_column, buf);
160 fl_deactivate_object(dialog_->input_tabular_column);
161 int row = tabular.row_of_cell(cell);
162 sprintf(buf, "%d", row + 1);
163 fl_set_input(dialog_->input_tabular_row, buf);
164 fl_deactivate_object(dialog_->input_tabular_row);
165 if (tabular.isMultiColumn(cell)) {
166 fl_set_button(cell_options_->check_multicolumn, 1);
167 fl_set_button(cell_options_->check_border_top,
168 tabular.topLine(cell)?1:0);
169 setEnabled(cell_options_->check_border_top, true);
170 fl_set_button(cell_options_->check_border_bottom,
171 tabular.bottomLine(cell)?1:0);
172 setEnabled(cell_options_->check_border_bottom, true);
173 // pay attention to left/right lines they are only allowed
174 // to set if we are in first/last cell of row or if the left/right
175 // cell is also a multicolumn.
176 if (tabular.isFirstCellInRow(cell) ||
177 tabular.isMultiColumn(cell-1)) {
178 fl_set_button(cell_options_->check_border_left,
179 tabular.leftLine(cell)?1:0);
180 setEnabled(cell_options_->check_border_left, true);
182 fl_set_button(cell_options_->check_border_left, 0);
183 setEnabled(cell_options_->check_border_left, false);
185 if (tabular.isLastCellInRow(cell) ||
186 tabular.isMultiColumn(cell+1)) {
187 fl_set_button(cell_options_->check_border_right,
188 tabular.rightLine(cell)?1:0);
189 setEnabled(cell_options_->check_border_right, true);
191 fl_set_button(cell_options_->check_border_right, 0);
192 setEnabled(cell_options_->check_border_right, false);
194 pwidth = tabular.getMColumnPWidth(cell);
195 align = tabular.getAlignment(cell);
196 // set the horiz. alignment, default is left here
197 fl_set_button(cell_options_->radio_align_left, 0);
198 fl_set_button(cell_options_->radio_align_right, 0);
199 fl_set_button(cell_options_->radio_align_center, 0);
200 if (align == LYX_ALIGN_RIGHT)
201 fl_set_button(cell_options_->radio_align_right, 1);
202 else if (align == LYX_ALIGN_CENTER)
203 fl_set_button(cell_options_->radio_align_center, 1);
205 fl_set_button(cell_options_->radio_align_left, 1);
207 align = tabular.getVAlignment(cell);
208 fl_set_button(cell_options_->radio_valign_top, 0);
209 fl_set_button(cell_options_->radio_valign_bottom, 0);
210 fl_set_button(cell_options_->radio_valign_middle, 0);
211 if (pwidth.zero() || (align == LyXTabular::LYX_VALIGN_MIDDLE))
212 fl_set_button(cell_options_->radio_valign_middle, 1);
213 else if (align == LyXTabular::LYX_VALIGN_BOTTOM)
214 fl_set_button(cell_options_->radio_valign_bottom, 1);
216 fl_set_button(cell_options_->radio_valign_top, 1);
218 special = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
219 fl_set_input(cell_options_->input_special_multialign, special.c_str());
220 bool const metric(controller().useMetricUnits());
221 string const default_unit = metric ? "cm" : "in";
222 updateWidgetsFromLength(cell_options_->input_mcolumn_width,
223 cell_options_->choice_value_mcolumn_width,
224 pwidth, default_unit);
226 if (!bc().bp().isReadOnly()) {
227 setEnabled(cell_options_->input_special_multialign, true);
228 setEnabled(cell_options_->input_mcolumn_width, true);
229 setEnabled(cell_options_->choice_value_mcolumn_width, true);
232 setEnabled(cell_options_->radio_valign_top, !pwidth.zero());
233 setEnabled(cell_options_->radio_valign_bottom, !pwidth.zero());
234 setEnabled(cell_options_->radio_valign_middle, !pwidth.zero());
236 setEnabled(cell_options_->radio_align_left, true);
237 setEnabled(cell_options_->radio_align_right, true);
238 setEnabled(cell_options_->radio_align_center, true);
240 fl_set_button(cell_options_->check_multicolumn, 0);
242 fl_set_button(cell_options_->check_border_top, 0);
243 setEnabled(cell_options_->check_border_top, false);
245 fl_set_button(cell_options_->check_border_bottom, 0);
246 setEnabled(cell_options_->check_border_bottom, false);
248 fl_set_button(cell_options_->check_border_left, 0);
249 setEnabled(cell_options_->check_border_left, false);
251 fl_set_button(cell_options_->check_border_right, 0);
252 setEnabled(cell_options_->check_border_right, false);
254 fl_set_button(cell_options_->radio_align_left, 0);
255 setEnabled(cell_options_->radio_align_left, false);
257 fl_set_button(cell_options_->radio_align_right, 0);
258 setEnabled(cell_options_->radio_align_right, false);
260 fl_set_button(cell_options_->radio_align_center, 0);
261 setEnabled(cell_options_->radio_align_center, false);
263 fl_set_button(cell_options_->radio_valign_top, 0);
264 setEnabled(cell_options_->radio_valign_top, false);
266 fl_set_button(cell_options_->radio_valign_bottom, 0);
267 setEnabled(cell_options_->radio_valign_bottom, false);
269 fl_set_button(cell_options_->radio_valign_middle, 0);
270 setEnabled(cell_options_->radio_valign_middle, false);
272 fl_set_input(cell_options_->input_special_multialign, "");
273 setEnabled(cell_options_->input_special_multialign, false);
275 fl_set_input(cell_options_->input_mcolumn_width, "");
276 setEnabled(cell_options_->input_mcolumn_width, false);
277 setEnabled(cell_options_->choice_value_mcolumn_width, false);
279 if (tabular.getRotateCell(cell))
280 fl_set_button(cell_options_->check_rotate_cell, 1);
282 fl_set_button(cell_options_->check_rotate_cell, 0);
283 if (tabular.topLine(cell, true))
284 fl_set_button(column_options_->check_border_top, 1);
286 fl_set_button(column_options_->check_border_top, 0);
287 if (tabular.bottomLine(cell, true))
288 fl_set_button(column_options_->check_border_bottom, 1);
290 fl_set_button(column_options_->check_border_bottom, 0);
291 if (tabular.leftLine(cell, true))
292 fl_set_button(column_options_->check_border_left, 1);
294 fl_set_button(column_options_->check_border_left, 0);
295 if (tabular.rightLine(cell, true))
296 fl_set_button(column_options_->check_border_right, 1);
298 fl_set_button(column_options_->check_border_right, 0);
299 special = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
300 fl_set_input(column_options_->input_special_alignment, special.c_str());
302 bool const isReadonly = bc().bp().isReadOnly();
303 setEnabled(column_options_->input_special_alignment, !isReadonly);
305 pwidth = tabular.getColumnPWidth(cell);
306 bool const metric = controller().useMetricUnits();
307 string const default_unit = metric ? "cm" : "in";
308 updateWidgetsFromLength(column_options_->input_column_width,
309 column_options_->choice_value_column_width,
310 pwidth, default_unit);
311 setEnabled(column_options_->input_column_width, !isReadonly);
312 setEnabled(column_options_->choice_value_column_width, !isReadonly);
314 setEnabled(cell_options_->check_useminipage, !pwidth.zero());
315 if (!pwidth.zero()) {
316 if (tabular.getUsebox(cell) == 2)
317 fl_set_button(cell_options_->check_useminipage, 1);
319 fl_set_button(cell_options_->check_useminipage, 0);
321 fl_set_button(cell_options_->check_useminipage, 0);
323 align = tabular.getAlignment(cell, true);
324 fl_set_button(column_options_->radio_align_left, 0);
325 fl_set_button(column_options_->radio_align_right, 0);
326 fl_set_button(column_options_->radio_align_center, 0);
327 fl_set_button(column_options_->radio_align_block, 0);
328 if (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 if (align == LYX_ALIGN_CENTER)
333 fl_set_button(column_options_->radio_align_center, 1);
335 fl_set_button(column_options_->radio_align_block, 1);
336 align = tabular.getVAlignment(cell, true);
337 fl_set_button(column_options_->radio_valign_top, 0);
338 fl_set_button(column_options_->radio_valign_bottom, 0);
339 fl_set_button(column_options_->radio_valign_middle, 0);
340 if (pwidth.zero() || (align == LyXTabular::LYX_VALIGN_MIDDLE))
341 fl_set_button(column_options_->radio_valign_middle, 1);
342 else if (align == LyXTabular::LYX_VALIGN_BOTTOM)
343 fl_set_button(column_options_->radio_valign_bottom, 1);
345 fl_set_button(column_options_->radio_valign_top, 1);
347 setEnabled(column_options_->radio_align_left, true);
348 setEnabled(column_options_->radio_align_right, true);
349 setEnabled(column_options_->radio_align_center, true);
350 setEnabled(column_options_->radio_align_block, !pwidth.zero());
351 setEnabled(column_options_->radio_valign_top, !pwidth.zero());
352 setEnabled(column_options_->radio_valign_bottom, !pwidth.zero());
353 setEnabled(column_options_->radio_valign_middle, !pwidth.zero());
355 fl_set_button(tabular_options_->check_longtable,
356 tabular.isLongTabular());
358 bool const enable = tabular.isLongTabular();
360 setEnabled(longtable_options_->check_lt_firsthead, enable);
361 setEnabled(longtable_options_->check_1head_2border_above, enable);
362 setEnabled(longtable_options_->check_1head_2border_below, enable);
363 setEnabled(longtable_options_->check_1head_empty, enable);
364 setEnabled(longtable_options_->check_lt_head, enable);
365 setEnabled(longtable_options_->check_head_2border_above, enable);
366 setEnabled(longtable_options_->check_head_2border_below, enable);
367 setEnabled(longtable_options_->check_lt_foot, enable);
368 setEnabled(longtable_options_->check_foot_2border_above, enable);
369 setEnabled(longtable_options_->check_foot_2border_below, enable);
370 setEnabled(longtable_options_->check_lt_lastfoot, enable);
371 setEnabled(longtable_options_->check_lastfoot_2border_above, enable);
372 setEnabled(longtable_options_->check_lastfoot_2border_below, enable);
373 setEnabled(longtable_options_->check_lastfoot_empty, enable);
374 setEnabled(longtable_options_->check_lt_newpage, enable);
377 LyXTabular::ltType ltt;
379 bool row_set = tabular.getRowOfLTHead(row, ltt);
380 fl_set_button(longtable_options_->check_lt_head, row_set);
382 fl_set_button(longtable_options_->check_head_2border_above,
384 fl_set_button(longtable_options_->check_head_2border_below,
388 setEnabled(longtable_options_->check_head_2border_above, 0);
389 setEnabled(longtable_options_->check_head_2border_below, 0);
390 fl_set_button(longtable_options_->check_head_2border_above,0);
391 fl_set_button(longtable_options_->check_head_2border_below,0);
392 fl_set_button(longtable_options_->check_1head_empty,0);
393 setEnabled(longtable_options_->check_1head_empty, 0);
397 row_set = tabular.getRowOfLTFirstHead(row, ltt);
398 fl_set_button(longtable_options_->check_lt_firsthead, row_set);
399 if (ltt.set && (!ltt.empty || !use_empty)) {
400 fl_set_button(longtable_options_->check_1head_2border_above,
402 fl_set_button(longtable_options_->check_1head_2border_below,
405 setEnabled(longtable_options_->check_1head_2border_above, 0);
406 setEnabled(longtable_options_->check_1head_2border_below, 0);
407 fl_set_button(longtable_options_->check_1head_2border_above,0);
408 fl_set_button(longtable_options_->check_1head_2border_below,0);
410 fl_set_button(longtable_options_->check_1head_empty,ltt.empty);
412 setEnabled(longtable_options_->check_lt_firsthead, 0);
416 row_set = tabular.getRowOfLTFoot(row, ltt);
417 fl_set_button(longtable_options_->check_lt_foot, row_set);
419 fl_set_button(longtable_options_->check_foot_2border_above,
421 fl_set_button(longtable_options_->check_foot_2border_below,
425 setEnabled(longtable_options_->check_foot_2border_above, 0);
426 setEnabled(longtable_options_->check_foot_2border_below, 0);
427 fl_set_button(longtable_options_->check_foot_2border_above,0);
428 fl_set_button(longtable_options_->check_foot_2border_below,0);
429 fl_set_button(longtable_options_->check_lastfoot_empty, 0);
430 setEnabled(longtable_options_->check_lastfoot_empty, 0);
434 row_set = tabular.getRowOfLTLastFoot(row, ltt);
435 fl_set_button(longtable_options_->check_lt_lastfoot, row_set);
436 if (ltt.set && (!ltt.empty || !use_empty)) {
437 fl_set_button(longtable_options_->check_lastfoot_2border_above,
439 fl_set_button(longtable_options_->check_lastfoot_2border_below,
442 setEnabled(longtable_options_->check_lastfoot_2border_above,0);
443 setEnabled(longtable_options_->check_lastfoot_2border_below,0);
444 fl_set_button(longtable_options_->check_lastfoot_2border_above, 0);
445 fl_set_button(longtable_options_->check_lastfoot_2border_below, 0);
447 fl_set_button(longtable_options_->check_lastfoot_empty,
450 setEnabled(longtable_options_->check_lt_lastfoot, 0);
453 fl_set_button(longtable_options_->check_lt_newpage,
454 tabular.getLTNewPage(row));
456 fl_set_button(longtable_options_->check_lt_firsthead, 0);
457 fl_set_button(longtable_options_->check_1head_2border_above, 0);
458 fl_set_button(longtable_options_->check_1head_2border_below, 0);
459 fl_set_button(longtable_options_->check_1head_empty, 0);
460 fl_set_button(longtable_options_->check_lt_head, 0);
461 fl_set_button(longtable_options_->check_head_2border_above, 0);
462 fl_set_button(longtable_options_->check_head_2border_below, 0);
463 fl_set_button(longtable_options_->check_lt_foot, 0);
464 fl_set_button(longtable_options_->check_foot_2border_above, 0);
465 fl_set_button(longtable_options_->check_foot_2border_below, 0);
466 fl_set_button(longtable_options_->check_lt_lastfoot, 0);
467 fl_set_button(longtable_options_->check_lastfoot_2border_above, 0);
468 fl_set_button(longtable_options_->check_lastfoot_2border_below, 0);
469 fl_set_button(longtable_options_->check_lastfoot_empty, 0);
470 fl_set_button(longtable_options_->check_lt_newpage, 0);
472 fl_set_button(tabular_options_->check_rotate_tabular,
473 tabular.getRotateTabular());
477 ButtonPolicy::SMInput FormTabular::input(FL_OBJECT * ob, long)
480 LyXTabular::Feature num = LyXTabular::LAST_ACTION;
483 LyXTabular const & tabular = controller().tabular();
485 int const cell = controller().getActiveCell();
487 // ugly hack to auto-apply the stuff that hasn't been
488 // yet. don't let this continue to exist ...
489 if (ob == dialog_->button_close) {
492 getLengthFromWidgets(column_options_->input_column_width,
493 column_options_->choice_value_column_width);
495 LyXLength llen = tabular.getColumnPWidth(cell);
497 w2 = llen.asString();
499 string mw1 = getLengthFromWidgets(cell_options_->input_mcolumn_width,
500 cell_options_->choice_value_mcolumn_width);
501 llen = tabular.getMColumnPWidth(cell);
506 mw2 = llen.asString();
508 string al1 = getString(column_options_->input_special_alignment);
509 string al2 = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
510 string mal1 = getString(cell_options_->input_special_multialign);
511 string mal2 = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
513 // we must do these all at the end
515 input(column_options_->input_column_width, 0);
517 input(cell_options_->input_mcolumn_width, 0);
519 input(column_options_->input_special_alignment, 0);
521 input(cell_options_->input_special_multialign, 0);
524 return ButtonPolicy::SMI_VALID;
527 if (actCell_ != cell) {
529 postWarning(_("Wrong Cursor position, updated window"));
530 return ButtonPolicy::SMI_VALID;
533 // No point in processing directives that you can't do anything with
534 // anyhow, so exit now if the buffer is read-only.
535 if (bc().bp().isReadOnly()) {
537 return ButtonPolicy::SMI_VALID;
540 if ((ob == column_options_->input_column_width) ||
541 (ob == column_options_->choice_value_column_width)) {
543 getLengthFromWidgets(column_options_->input_column_width,
544 column_options_->choice_value_column_width);
545 controller().set(LyXTabular::SET_PWIDTH, str);
547 //check if the input is valid
548 string const input = getString(column_options_->input_column_width);
549 if (!input.empty() && !isValidLength(input) && !isStrDbl(input)) {
550 postWarning(_("Invalid Length (valid example: 10mm)"));
551 return ButtonPolicy::SMI_INVALID;
554 update(); // update for alignment
555 return ButtonPolicy::SMI_VALID;
558 if ((ob == cell_options_->input_mcolumn_width) ||
559 (ob == cell_options_->choice_value_mcolumn_width)) {
561 getLengthFromWidgets(cell_options_->input_mcolumn_width,
562 cell_options_->choice_value_mcolumn_width);
563 controller().set(LyXTabular::SET_MPWIDTH, str);
565 //check if the input is valid
566 string const input = getString(cell_options_->input_mcolumn_width);
567 if (!input.empty() && !isValidLength(input) && !isStrDbl(input)) {
568 postWarning(_("Invalid Length (valid example: 10mm)"));
569 return ButtonPolicy::SMI_INVALID;
571 update(); // update for alignment
572 return ButtonPolicy::SMI_VALID;
575 if (ob == tabular_options_->button_append_row)
576 num = LyXTabular::APPEND_ROW;
577 else if (ob == tabular_options_->button_append_column)
578 num = LyXTabular::APPEND_COLUMN;
579 else if (ob == tabular_options_->button_delete_row)
580 num = LyXTabular::DELETE_ROW;
581 else if (ob == tabular_options_->button_delete_column)
582 num = LyXTabular::DELETE_COLUMN;
583 else if (ob == tabular_options_->button_set_borders)
584 num = LyXTabular::SET_ALL_LINES;
585 else if (ob == tabular_options_->button_unset_borders)
586 num = LyXTabular::UNSET_ALL_LINES;
587 else if (ob == column_options_->check_border_top)
588 num = LyXTabular::TOGGLE_LINE_TOP;
589 else if (ob == column_options_->check_border_bottom)
590 num = LyXTabular::TOGGLE_LINE_BOTTOM;
591 else if (ob == column_options_->check_border_left)
592 num = LyXTabular::TOGGLE_LINE_LEFT;
593 else if (ob == column_options_->check_border_right)
594 num = LyXTabular::TOGGLE_LINE_RIGHT;
595 else if (ob == column_options_->radio_align_left)
596 num = LyXTabular::ALIGN_LEFT;
597 else if (ob == column_options_->radio_align_right)
598 num = LyXTabular::ALIGN_RIGHT;
599 else if (ob == column_options_->radio_align_center)
600 num = LyXTabular::ALIGN_CENTER;
601 else if (ob == column_options_->radio_align_block)
602 num = LyXTabular::ALIGN_BLOCK;
603 else if (ob == column_options_->radio_valign_top)
604 num = LyXTabular::VALIGN_TOP;
605 else if (ob == column_options_->radio_valign_bottom)
606 num = LyXTabular::VALIGN_BOTTOM;
607 else if (ob == column_options_->radio_valign_middle)
608 num = LyXTabular::VALIGN_MIDDLE;
609 else if (ob == cell_options_->check_multicolumn)
610 num = LyXTabular::MULTICOLUMN;
611 else if (ob == tabular_options_->check_longtable) {
612 if (fl_get_button(tabular_options_->check_longtable))
613 num = LyXTabular::SET_LONGTABULAR;
615 num = LyXTabular::UNSET_LONGTABULAR;
616 } else if (ob == tabular_options_->check_rotate_tabular) {
617 s = fl_get_button(tabular_options_->check_rotate_tabular);
619 num = LyXTabular::SET_ROTATE_TABULAR;
621 num = LyXTabular::UNSET_ROTATE_TABULAR;
622 } else if (ob == cell_options_->check_rotate_cell) {
623 s = fl_get_button(cell_options_->check_rotate_cell);
625 num = LyXTabular::SET_ROTATE_CELL;
627 num = LyXTabular::UNSET_ROTATE_CELL;
628 } else if (ob == cell_options_->check_useminipage) {
629 num = LyXTabular::SET_USEBOX;
631 } else if ((ob == longtable_options_->check_lt_firsthead) ||
632 (ob == longtable_options_->check_1head_2border_above) ||
633 (ob == longtable_options_->check_1head_2border_below) ||
634 (ob == longtable_options_->check_1head_empty) ||
635 (ob == longtable_options_->check_lt_head) ||
636 (ob == longtable_options_->check_head_2border_above) ||
637 (ob == longtable_options_->check_head_2border_below) ||
638 (ob == longtable_options_->check_lt_foot) ||
639 (ob == longtable_options_->check_foot_2border_above) ||
640 (ob == longtable_options_->check_foot_2border_below) ||
641 (ob == longtable_options_->check_lt_lastfoot) ||
642 (ob == longtable_options_->check_lastfoot_2border_above) ||
643 (ob == longtable_options_->check_lastfoot_2border_below) ||
644 (ob == longtable_options_->check_lastfoot_empty)) {
645 num = static_cast<LyXTabular::Feature>(checkLongtableOptions(ob, special));
646 } else if (ob == longtable_options_->check_lt_newpage) {
647 num = LyXTabular::SET_LTNEWPAGE;
648 } else if (ob == column_options_->input_special_alignment) {
649 special = getString(column_options_->input_special_alignment);
650 num = LyXTabular::SET_SPECIAL_COLUMN;
651 } else if (ob == cell_options_->input_special_multialign) {
652 special = getString(cell_options_->input_special_multialign);
653 num = LyXTabular::SET_SPECIAL_MULTI;
654 } else if (ob == cell_options_->check_border_top)
655 num = LyXTabular::M_TOGGLE_LINE_TOP;
656 else if (ob == cell_options_->check_border_bottom)
657 num = LyXTabular::M_TOGGLE_LINE_BOTTOM;
658 else if (ob == cell_options_->check_border_left)
659 num = LyXTabular::M_TOGGLE_LINE_LEFT;
660 else if (ob == cell_options_->check_border_right)
661 num = LyXTabular::M_TOGGLE_LINE_RIGHT;
662 else if (ob == cell_options_->radio_align_left)
663 num = LyXTabular::M_ALIGN_LEFT;
664 else if (ob == cell_options_->radio_align_right)
665 num = LyXTabular::M_ALIGN_RIGHT;
666 else if (ob == cell_options_->radio_align_center)
667 num = LyXTabular::M_ALIGN_CENTER;
668 else if (ob == cell_options_->radio_valign_top)
669 num = LyXTabular::M_VALIGN_TOP;
670 else if (ob == cell_options_->radio_valign_bottom)
671 num = LyXTabular::M_VALIGN_BOTTOM;
672 else if (ob == cell_options_->radio_valign_middle)
673 num = LyXTabular::M_VALIGN_MIDDLE;
675 return ButtonPolicy::SMI_VALID;
677 controller().set(num, special);
680 return ButtonPolicy::SMI_VALID;
684 int FormTabular::checkLongtableOptions(FL_OBJECT * ob, string & special)
686 bool flag = fl_get_button(ob);
687 if ((ob == longtable_options_->check_1head_2border_above) ||
688 (ob == longtable_options_->check_head_2border_above) ||
689 (ob == longtable_options_->check_foot_2border_above) ||
690 (ob == longtable_options_->check_lastfoot_2border_above)) {
691 special = "dl_above";
692 } else if ((ob == longtable_options_->check_1head_2border_below) ||
693 (ob == longtable_options_->check_head_2border_below) ||
694 (ob == longtable_options_->check_foot_2border_below) ||
695 (ob == longtable_options_->check_lastfoot_2border_below)) {
696 special = "dl_below";
697 } else if ((ob == longtable_options_->check_1head_empty) ||
698 (ob == longtable_options_->check_lastfoot_empty)) {
703 if ((ob == longtable_options_->check_lt_firsthead) ||
704 (ob == longtable_options_->check_1head_2border_above) ||
705 (ob == longtable_options_->check_1head_2border_below) ||
706 (ob == longtable_options_->check_1head_empty)) {
707 return (flag ? LyXTabular::SET_LTFIRSTHEAD :
708 LyXTabular::UNSET_LTFIRSTHEAD);
709 } else if ((ob == longtable_options_->check_lt_head) ||
710 (ob == longtable_options_->check_head_2border_above) ||
711 (ob == longtable_options_->check_head_2border_below)) {
712 return (flag ? LyXTabular::SET_LTHEAD : LyXTabular::UNSET_LTHEAD);
713 } else if ((ob == longtable_options_->check_lt_foot) ||
714 (ob == longtable_options_->check_foot_2border_above) ||
715 (ob == longtable_options_->check_foot_2border_below)) {
716 return (flag ? LyXTabular::SET_LTFOOT : LyXTabular::UNSET_LTFOOT);
717 } else if ((ob == longtable_options_->check_lt_lastfoot) ||
718 (ob == longtable_options_->check_lastfoot_2border_above) ||
719 (ob == longtable_options_->check_lastfoot_2border_below) ||
720 (ob == longtable_options_->check_lastfoot_empty)) {
721 return (flag ? LyXTabular::SET_LTLASTFOOT :
722 LyXTabular::UNSET_LTLASTFOOT);
725 return LyXTabular::LAST_ACTION;