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 lyx::support::contains_functor;
28 using lyx::support::getStringFromVector;
29 using lyx::support::isStrDbl;
38 #if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL < 2)
39 bool const scalableTabfolders = false;
41 bool const scalableTabfolders = true;
47 typedef FormController<ControlTabular, FormView<FD_tabular> > base_class;
49 FormTabular::FormTabular(Dialog & parent)
50 : base_class(parent, _("Table Settings"), scalableTabfolders),
51 closing_(false), actCell_(-1)
56 void FormTabular::redraw()
58 if (form() && form()->visible)
59 fl_redraw_form(form());
63 FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder);
64 if (outer_form && outer_form->visible)
65 fl_redraw_form(outer_form);
69 void FormTabular::build()
71 dialog_.reset(build_tabular(this));
73 // Allow the base class to control messages
74 setMessageWidget(dialog_->text_warning);
76 // trigger an input event for cut&paste with middle mouse button.
77 setPrehandler(dialog_->input_tabular_column);
78 setPrehandler(dialog_->input_tabular_row);
80 // Create the contents of the unit choices; don't include the "%" terms.
81 vector<string> units_vec = getLatexUnits();
82 vector<string>::iterator ret =
83 remove_if(units_vec.begin(), units_vec.end(),
84 bind2nd(contains_functor(), "%"));
85 units_vec.erase(ret, units_vec.end());
86 string const units = getStringFromVector(units_vec, "|");
88 // tabular options form
89 tabular_options_.reset(build_tabular_options(this));
91 // column options form
92 column_options_.reset(build_tabular_column(this));
94 fl_set_input_return(column_options_->input_column_width,
96 fl_set_input_return(column_options_->input_special_alignment,
99 // trigger an input event for cut&paste with middle mouse button.
100 setPrehandler(column_options_->input_column_width);
101 setPrehandler(column_options_->input_special_alignment);
103 fl_addto_choice(column_options_->choice_value_column_width,
107 cell_options_.reset(build_tabular_cell(this));
109 fl_set_input_return(cell_options_->input_mcolumn_width,
111 fl_set_input_return(cell_options_->input_special_multialign,
114 // trigger an input event for cut&paste with middle mouse button.
115 setPrehandler(cell_options_->input_mcolumn_width);
116 setPrehandler(cell_options_->input_special_multialign);
118 fl_addto_choice(cell_options_->choice_value_mcolumn_width,
121 longtable_options_.reset(build_tabular_longtable(this));
123 // Enable the tabfolder to be rescaled correctly.
124 if (scalableTabfolders)
125 fl_set_tabfolder_autofit(dialog_->tabfolder, FL_FIT);
128 fl_addto_tabfolder(dialog_->tabfolder, _("Table").c_str(),
129 tabular_options_->form);
130 fl_addto_tabfolder(dialog_->tabfolder, _("Column/Row").c_str(),
131 column_options_->form);
132 fl_addto_tabfolder(dialog_->tabfolder, _("Cell").c_str(),
133 cell_options_->form);
134 fl_addto_tabfolder(dialog_->tabfolder, _("LongTable").c_str(),
135 longtable_options_->form);
137 // FIXME: addReadOnly everything
141 void FormTabular::update()
146 LyXTabular const & tabular = controller().tabular();
153 int const cell = controller().getActiveCell();
155 int column = tabular.column_of_cell(cell) + 1;
157 fl_activate_object(column_options_->input_special_alignment);
158 fl_activate_object(cell_options_->input_special_multialign);
159 fl_activate_object(column_options_->input_column_width);
160 fl_activate_object(column_options_->choice_value_column_width);
161 sprintf(buf, "%d", column);
162 fl_set_input(dialog_->input_tabular_column, buf);
163 fl_deactivate_object(dialog_->input_tabular_column);
164 int row = tabular.row_of_cell(cell);
165 sprintf(buf, "%d", row + 1);
166 fl_set_input(dialog_->input_tabular_row, buf);
167 fl_deactivate_object(dialog_->input_tabular_row);
168 if (tabular.isMultiColumn(cell)) {
169 fl_set_button(cell_options_->check_multicolumn, 1);
170 fl_set_button(cell_options_->check_border_top,
171 tabular.topLine(cell)?1:0);
172 setEnabled(cell_options_->check_border_top, true);
173 fl_set_button(cell_options_->check_border_bottom,
174 tabular.bottomLine(cell)?1:0);
175 setEnabled(cell_options_->check_border_bottom, true);
176 // pay attention to left/right lines they are only allowed
177 // to set if we are in first/last cell of row or if the left/right
178 // cell is also a multicolumn.
179 if (tabular.isFirstCellInRow(cell) ||
180 tabular.isMultiColumn(cell-1)) {
181 fl_set_button(cell_options_->check_border_left,
182 tabular.leftLine(cell)?1:0);
183 setEnabled(cell_options_->check_border_left, true);
185 fl_set_button(cell_options_->check_border_left, 0);
186 setEnabled(cell_options_->check_border_left, false);
188 if (tabular.isLastCellInRow(cell) ||
189 tabular.isMultiColumn(cell+1)) {
190 fl_set_button(cell_options_->check_border_right,
191 tabular.rightLine(cell)?1:0);
192 setEnabled(cell_options_->check_border_right, true);
194 fl_set_button(cell_options_->check_border_right, 0);
195 setEnabled(cell_options_->check_border_right, false);
197 pwidth = tabular.getMColumnPWidth(cell);
198 align = tabular.getAlignment(cell);
199 // set the horiz. alignment, default is left here
200 fl_set_button(cell_options_->radio_align_left, 0);
201 fl_set_button(cell_options_->radio_align_right, 0);
202 fl_set_button(cell_options_->radio_align_center, 0);
203 if (align == LYX_ALIGN_RIGHT)
204 fl_set_button(cell_options_->radio_align_right, 1);
205 else if (align == LYX_ALIGN_CENTER)
206 fl_set_button(cell_options_->radio_align_center, 1);
208 fl_set_button(cell_options_->radio_align_left, 1);
210 align = tabular.getVAlignment(cell);
211 fl_set_button(cell_options_->radio_valign_top, 0);
212 fl_set_button(cell_options_->radio_valign_bottom, 0);
213 fl_set_button(cell_options_->radio_valign_middle, 0);
214 if (pwidth.zero() || (align == LyXTabular::LYX_VALIGN_MIDDLE))
215 fl_set_button(cell_options_->radio_valign_middle, 1);
216 else if (align == LyXTabular::LYX_VALIGN_BOTTOM)
217 fl_set_button(cell_options_->radio_valign_bottom, 1);
219 fl_set_button(cell_options_->radio_valign_top, 1);
221 special = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
222 fl_set_input(cell_options_->input_special_multialign, special.c_str());
223 bool const metric(controller().useMetricUnits());
224 string const default_unit = metric ? "cm" : "in";
225 updateWidgetsFromLength(cell_options_->input_mcolumn_width,
226 cell_options_->choice_value_mcolumn_width,
227 pwidth, default_unit);
229 if (!bc().bp().isReadOnly()) {
230 setEnabled(cell_options_->input_special_multialign, true);
231 setEnabled(cell_options_->input_mcolumn_width, true);
232 setEnabled(cell_options_->choice_value_mcolumn_width, true);
235 setEnabled(cell_options_->radio_valign_top, !pwidth.zero());
236 setEnabled(cell_options_->radio_valign_bottom, !pwidth.zero());
237 setEnabled(cell_options_->radio_valign_middle, !pwidth.zero());
239 setEnabled(cell_options_->radio_align_left, true);
240 setEnabled(cell_options_->radio_align_right, true);
241 setEnabled(cell_options_->radio_align_center, true);
243 fl_set_button(cell_options_->check_multicolumn, 0);
245 fl_set_button(cell_options_->check_border_top, 0);
246 setEnabled(cell_options_->check_border_top, false);
248 fl_set_button(cell_options_->check_border_bottom, 0);
249 setEnabled(cell_options_->check_border_bottom, false);
251 fl_set_button(cell_options_->check_border_left, 0);
252 setEnabled(cell_options_->check_border_left, false);
254 fl_set_button(cell_options_->check_border_right, 0);
255 setEnabled(cell_options_->check_border_right, false);
257 fl_set_button(cell_options_->radio_align_left, 0);
258 setEnabled(cell_options_->radio_align_left, false);
260 fl_set_button(cell_options_->radio_align_right, 0);
261 setEnabled(cell_options_->radio_align_right, false);
263 fl_set_button(cell_options_->radio_align_center, 0);
264 setEnabled(cell_options_->radio_align_center, false);
266 fl_set_button(cell_options_->radio_valign_top, 0);
267 setEnabled(cell_options_->radio_valign_top, false);
269 fl_set_button(cell_options_->radio_valign_bottom, 0);
270 setEnabled(cell_options_->radio_valign_bottom, false);
272 fl_set_button(cell_options_->radio_valign_middle, 0);
273 setEnabled(cell_options_->radio_valign_middle, false);
275 fl_set_input(cell_options_->input_special_multialign, "");
276 setEnabled(cell_options_->input_special_multialign, false);
278 fl_set_input(cell_options_->input_mcolumn_width, "");
279 setEnabled(cell_options_->input_mcolumn_width, false);
280 setEnabled(cell_options_->choice_value_mcolumn_width, false);
282 if (tabular.getRotateCell(cell))
283 fl_set_button(cell_options_->check_rotate_cell, 1);
285 fl_set_button(cell_options_->check_rotate_cell, 0);
286 if (tabular.topLine(cell, true))
287 fl_set_button(column_options_->check_border_top, 1);
289 fl_set_button(column_options_->check_border_top, 0);
290 if (tabular.bottomLine(cell, true))
291 fl_set_button(column_options_->check_border_bottom, 1);
293 fl_set_button(column_options_->check_border_bottom, 0);
294 if (tabular.leftLine(cell, true))
295 fl_set_button(column_options_->check_border_left, 1);
297 fl_set_button(column_options_->check_border_left, 0);
298 if (tabular.rightLine(cell, true))
299 fl_set_button(column_options_->check_border_right, 1);
301 fl_set_button(column_options_->check_border_right, 0);
302 special = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
303 fl_set_input(column_options_->input_special_alignment, special.c_str());
305 bool const isReadonly = bc().bp().isReadOnly();
306 setEnabled(column_options_->input_special_alignment, !isReadonly);
308 pwidth = tabular.getColumnPWidth(cell);
309 bool const metric = controller().useMetricUnits();
310 string const default_unit = metric ? "cm" : "in";
311 updateWidgetsFromLength(column_options_->input_column_width,
312 column_options_->choice_value_column_width,
313 pwidth, default_unit);
314 setEnabled(column_options_->input_column_width, !isReadonly);
315 setEnabled(column_options_->choice_value_column_width, !isReadonly);
317 setEnabled(cell_options_->check_useminipage, !pwidth.zero());
318 if (!pwidth.zero()) {
319 if (tabular.getUsebox(cell) == 2)
320 fl_set_button(cell_options_->check_useminipage, 1);
322 fl_set_button(cell_options_->check_useminipage, 0);
324 fl_set_button(cell_options_->check_useminipage, 0);
326 align = tabular.getAlignment(cell, true);
327 fl_set_button(column_options_->radio_align_left, 0);
328 fl_set_button(column_options_->radio_align_right, 0);
329 fl_set_button(column_options_->radio_align_center, 0);
330 fl_set_button(column_options_->radio_align_block, 0);
331 if (align == LYX_ALIGN_LEFT)
332 fl_set_button(column_options_->radio_align_left, 1);
333 else if (align == LYX_ALIGN_RIGHT)
334 fl_set_button(column_options_->radio_align_right, 1);
335 else if (align == LYX_ALIGN_CENTER)
336 fl_set_button(column_options_->radio_align_center, 1);
338 fl_set_button(column_options_->radio_align_block, 1);
339 align = tabular.getVAlignment(cell, true);
340 fl_set_button(column_options_->radio_valign_top, 0);
341 fl_set_button(column_options_->radio_valign_bottom, 0);
342 fl_set_button(column_options_->radio_valign_middle, 0);
343 if (pwidth.zero() || (align == LyXTabular::LYX_VALIGN_MIDDLE))
344 fl_set_button(column_options_->radio_valign_middle, 1);
345 else if (align == LyXTabular::LYX_VALIGN_BOTTOM)
346 fl_set_button(column_options_->radio_valign_bottom, 1);
348 fl_set_button(column_options_->radio_valign_top, 1);
350 setEnabled(column_options_->radio_align_left, true);
351 setEnabled(column_options_->radio_align_right, true);
352 setEnabled(column_options_->radio_align_center, true);
353 setEnabled(column_options_->radio_align_block, !pwidth.zero());
354 setEnabled(column_options_->radio_valign_top, !pwidth.zero());
355 setEnabled(column_options_->radio_valign_bottom, !pwidth.zero());
356 setEnabled(column_options_->radio_valign_middle, !pwidth.zero());
358 fl_set_button(tabular_options_->check_longtable,
359 tabular.isLongTabular());
361 bool const enable = tabular.isLongTabular();
363 setEnabled(longtable_options_->check_lt_firsthead, enable);
364 setEnabled(longtable_options_->check_1head_2border_above, enable);
365 setEnabled(longtable_options_->check_1head_2border_below, enable);
366 setEnabled(longtable_options_->check_1head_empty, enable);
367 setEnabled(longtable_options_->check_lt_head, enable);
368 setEnabled(longtable_options_->check_head_2border_above, enable);
369 setEnabled(longtable_options_->check_head_2border_below, enable);
370 setEnabled(longtable_options_->check_lt_foot, enable);
371 setEnabled(longtable_options_->check_foot_2border_above, enable);
372 setEnabled(longtable_options_->check_foot_2border_below, enable);
373 setEnabled(longtable_options_->check_lt_lastfoot, enable);
374 setEnabled(longtable_options_->check_lastfoot_2border_above, enable);
375 setEnabled(longtable_options_->check_lastfoot_2border_below, enable);
376 setEnabled(longtable_options_->check_lastfoot_empty, enable);
377 setEnabled(longtable_options_->check_lt_newpage, enable);
380 LyXTabular::ltType ltt;
382 bool row_set = tabular.getRowOfLTHead(row, ltt);
383 fl_set_button(longtable_options_->check_lt_head, row_set);
385 fl_set_button(longtable_options_->check_head_2border_above,
387 fl_set_button(longtable_options_->check_head_2border_below,
391 setEnabled(longtable_options_->check_head_2border_above, 0);
392 setEnabled(longtable_options_->check_head_2border_below, 0);
393 fl_set_button(longtable_options_->check_head_2border_above,0);
394 fl_set_button(longtable_options_->check_head_2border_below,0);
395 fl_set_button(longtable_options_->check_1head_empty,0);
396 setEnabled(longtable_options_->check_1head_empty, 0);
400 row_set = tabular.getRowOfLTFirstHead(row, ltt);
401 fl_set_button(longtable_options_->check_lt_firsthead, row_set);
402 if (ltt.set && (!ltt.empty || !use_empty)) {
403 fl_set_button(longtable_options_->check_1head_2border_above,
405 fl_set_button(longtable_options_->check_1head_2border_below,
408 setEnabled(longtable_options_->check_1head_2border_above, 0);
409 setEnabled(longtable_options_->check_1head_2border_below, 0);
410 fl_set_button(longtable_options_->check_1head_2border_above,0);
411 fl_set_button(longtable_options_->check_1head_2border_below,0);
413 fl_set_button(longtable_options_->check_1head_empty,ltt.empty);
415 setEnabled(longtable_options_->check_lt_firsthead, 0);
419 row_set = tabular.getRowOfLTFoot(row, ltt);
420 fl_set_button(longtable_options_->check_lt_foot, row_set);
422 fl_set_button(longtable_options_->check_foot_2border_above,
424 fl_set_button(longtable_options_->check_foot_2border_below,
428 setEnabled(longtable_options_->check_foot_2border_above, 0);
429 setEnabled(longtable_options_->check_foot_2border_below, 0);
430 fl_set_button(longtable_options_->check_foot_2border_above,0);
431 fl_set_button(longtable_options_->check_foot_2border_below,0);
432 fl_set_button(longtable_options_->check_lastfoot_empty, 0);
433 setEnabled(longtable_options_->check_lastfoot_empty, 0);
437 row_set = tabular.getRowOfLTLastFoot(row, ltt);
438 fl_set_button(longtable_options_->check_lt_lastfoot, row_set);
439 if (ltt.set && (!ltt.empty || !use_empty)) {
440 fl_set_button(longtable_options_->check_lastfoot_2border_above,
442 fl_set_button(longtable_options_->check_lastfoot_2border_below,
445 setEnabled(longtable_options_->check_lastfoot_2border_above,0);
446 setEnabled(longtable_options_->check_lastfoot_2border_below,0);
447 fl_set_button(longtable_options_->check_lastfoot_2border_above, 0);
448 fl_set_button(longtable_options_->check_lastfoot_2border_below, 0);
450 fl_set_button(longtable_options_->check_lastfoot_empty,
453 setEnabled(longtable_options_->check_lt_lastfoot, 0);
456 fl_set_button(longtable_options_->check_lt_newpage,
457 tabular.getLTNewPage(row));
459 fl_set_button(longtable_options_->check_lt_firsthead, 0);
460 fl_set_button(longtable_options_->check_1head_2border_above, 0);
461 fl_set_button(longtable_options_->check_1head_2border_below, 0);
462 fl_set_button(longtable_options_->check_1head_empty, 0);
463 fl_set_button(longtable_options_->check_lt_head, 0);
464 fl_set_button(longtable_options_->check_head_2border_above, 0);
465 fl_set_button(longtable_options_->check_head_2border_below, 0);
466 fl_set_button(longtable_options_->check_lt_foot, 0);
467 fl_set_button(longtable_options_->check_foot_2border_above, 0);
468 fl_set_button(longtable_options_->check_foot_2border_below, 0);
469 fl_set_button(longtable_options_->check_lt_lastfoot, 0);
470 fl_set_button(longtable_options_->check_lastfoot_2border_above, 0);
471 fl_set_button(longtable_options_->check_lastfoot_2border_below, 0);
472 fl_set_button(longtable_options_->check_lastfoot_empty, 0);
473 fl_set_button(longtable_options_->check_lt_newpage, 0);
475 fl_set_button(tabular_options_->check_rotate_tabular,
476 tabular.getRotateTabular());
480 ButtonPolicy::SMInput FormTabular::input(FL_OBJECT * ob, long)
483 LyXTabular::Feature num = LyXTabular::LAST_ACTION;
486 LyXTabular const & tabular = controller().tabular();
488 int const cell = controller().getActiveCell();
490 // ugly hack to auto-apply the stuff that hasn't been
491 // yet. don't let this continue to exist ...
492 if (ob == dialog_->button_close) {
495 getLengthFromWidgets(column_options_->input_column_width,
496 column_options_->choice_value_column_width);
498 LyXLength llen = tabular.getColumnPWidth(cell);
500 w2 = llen.asString();
502 string mw1 = getLengthFromWidgets(cell_options_->input_mcolumn_width,
503 cell_options_->choice_value_mcolumn_width);
504 llen = tabular.getMColumnPWidth(cell);
509 mw2 = llen.asString();
511 string al1 = getString(column_options_->input_special_alignment);
512 string al2 = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
513 string mal1 = getString(cell_options_->input_special_multialign);
514 string mal2 = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
516 // we must do these all at the end
518 input(column_options_->input_column_width, 0);
520 input(cell_options_->input_mcolumn_width, 0);
522 input(column_options_->input_special_alignment, 0);
524 input(cell_options_->input_special_multialign, 0);
527 return ButtonPolicy::SMI_VALID;
530 if (actCell_ != cell) {
532 postWarning(_("Wrong Cursor position, updated window"));
533 return ButtonPolicy::SMI_VALID;
536 // No point in processing directives that you can't do anything with
537 // anyhow, so exit now if the buffer is read-only.
538 if (bc().bp().isReadOnly()) {
540 return ButtonPolicy::SMI_VALID;
543 if ((ob == column_options_->input_column_width) ||
544 (ob == column_options_->choice_value_column_width)) {
546 getLengthFromWidgets(column_options_->input_column_width,
547 column_options_->choice_value_column_width);
548 controller().set(LyXTabular::SET_PWIDTH, str);
550 //check if the input is valid
551 string const input = getString(column_options_->input_column_width);
552 if (!input.empty() && !isValidLength(input) && !isStrDbl(input)) {
553 postWarning(_("Invalid Length (valid example: 10mm)"));
554 return ButtonPolicy::SMI_INVALID;
557 update(); // update for alignment
558 return ButtonPolicy::SMI_VALID;
561 if ((ob == cell_options_->input_mcolumn_width) ||
562 (ob == cell_options_->choice_value_mcolumn_width)) {
564 getLengthFromWidgets(cell_options_->input_mcolumn_width,
565 cell_options_->choice_value_mcolumn_width);
566 controller().set(LyXTabular::SET_MPWIDTH, str);
568 //check if the input is valid
569 string const input = getString(cell_options_->input_mcolumn_width);
570 if (!input.empty() && !isValidLength(input) && !isStrDbl(input)) {
571 postWarning(_("Invalid Length (valid example: 10mm)"));
572 return ButtonPolicy::SMI_INVALID;
574 update(); // update for alignment
575 return ButtonPolicy::SMI_VALID;
578 if (ob == tabular_options_->button_append_row)
579 num = LyXTabular::APPEND_ROW;
580 else if (ob == tabular_options_->button_append_column)
581 num = LyXTabular::APPEND_COLUMN;
582 else if (ob == tabular_options_->button_delete_row)
583 num = LyXTabular::DELETE_ROW;
584 else if (ob == tabular_options_->button_delete_column)
585 num = LyXTabular::DELETE_COLUMN;
586 else if (ob == tabular_options_->button_set_borders)
587 num = LyXTabular::SET_ALL_LINES;
588 else if (ob == tabular_options_->button_unset_borders)
589 num = LyXTabular::UNSET_ALL_LINES;
590 else if (ob == column_options_->check_border_top)
591 num = LyXTabular::TOGGLE_LINE_TOP;
592 else if (ob == column_options_->check_border_bottom)
593 num = LyXTabular::TOGGLE_LINE_BOTTOM;
594 else if (ob == column_options_->check_border_left)
595 num = LyXTabular::TOGGLE_LINE_LEFT;
596 else if (ob == column_options_->check_border_right)
597 num = LyXTabular::TOGGLE_LINE_RIGHT;
598 else if (ob == column_options_->radio_align_left)
599 num = LyXTabular::ALIGN_LEFT;
600 else if (ob == column_options_->radio_align_right)
601 num = LyXTabular::ALIGN_RIGHT;
602 else if (ob == column_options_->radio_align_center)
603 num = LyXTabular::ALIGN_CENTER;
604 else if (ob == column_options_->radio_align_block)
605 num = LyXTabular::ALIGN_BLOCK;
606 else if (ob == column_options_->radio_valign_top)
607 num = LyXTabular::VALIGN_TOP;
608 else if (ob == column_options_->radio_valign_bottom)
609 num = LyXTabular::VALIGN_BOTTOM;
610 else if (ob == column_options_->radio_valign_middle)
611 num = LyXTabular::VALIGN_MIDDLE;
612 else if (ob == cell_options_->check_multicolumn)
613 num = LyXTabular::MULTICOLUMN;
614 else if (ob == tabular_options_->check_longtable) {
615 if (fl_get_button(tabular_options_->check_longtable))
616 num = LyXTabular::SET_LONGTABULAR;
618 num = LyXTabular::UNSET_LONGTABULAR;
619 } else if (ob == tabular_options_->check_rotate_tabular) {
620 s = fl_get_button(tabular_options_->check_rotate_tabular);
622 num = LyXTabular::SET_ROTATE_TABULAR;
624 num = LyXTabular::UNSET_ROTATE_TABULAR;
625 } else if (ob == cell_options_->check_rotate_cell) {
626 s = fl_get_button(cell_options_->check_rotate_cell);
628 num = LyXTabular::SET_ROTATE_CELL;
630 num = LyXTabular::UNSET_ROTATE_CELL;
631 } else if (ob == cell_options_->check_useminipage) {
632 num = LyXTabular::SET_USEBOX;
634 } else if ((ob == longtable_options_->check_lt_firsthead) ||
635 (ob == longtable_options_->check_1head_2border_above) ||
636 (ob == longtable_options_->check_1head_2border_below) ||
637 (ob == longtable_options_->check_1head_empty) ||
638 (ob == longtable_options_->check_lt_head) ||
639 (ob == longtable_options_->check_head_2border_above) ||
640 (ob == longtable_options_->check_head_2border_below) ||
641 (ob == longtable_options_->check_lt_foot) ||
642 (ob == longtable_options_->check_foot_2border_above) ||
643 (ob == longtable_options_->check_foot_2border_below) ||
644 (ob == longtable_options_->check_lt_lastfoot) ||
645 (ob == longtable_options_->check_lastfoot_2border_above) ||
646 (ob == longtable_options_->check_lastfoot_2border_below) ||
647 (ob == longtable_options_->check_lastfoot_empty)) {
648 num = static_cast<LyXTabular::Feature>(checkLongtableOptions(ob, special));
649 } else if (ob == longtable_options_->check_lt_newpage) {
650 num = LyXTabular::SET_LTNEWPAGE;
651 } else if (ob == column_options_->input_special_alignment) {
652 special = getString(column_options_->input_special_alignment);
653 num = LyXTabular::SET_SPECIAL_COLUMN;
654 } else if (ob == cell_options_->input_special_multialign) {
655 special = getString(cell_options_->input_special_multialign);
656 num = LyXTabular::SET_SPECIAL_MULTI;
657 } else if (ob == cell_options_->check_border_top)
658 num = LyXTabular::M_TOGGLE_LINE_TOP;
659 else if (ob == cell_options_->check_border_bottom)
660 num = LyXTabular::M_TOGGLE_LINE_BOTTOM;
661 else if (ob == cell_options_->check_border_left)
662 num = LyXTabular::M_TOGGLE_LINE_LEFT;
663 else if (ob == cell_options_->check_border_right)
664 num = LyXTabular::M_TOGGLE_LINE_RIGHT;
665 else if (ob == cell_options_->radio_align_left)
666 num = LyXTabular::M_ALIGN_LEFT;
667 else if (ob == cell_options_->radio_align_right)
668 num = LyXTabular::M_ALIGN_RIGHT;
669 else if (ob == cell_options_->radio_align_center)
670 num = LyXTabular::M_ALIGN_CENTER;
671 else if (ob == cell_options_->radio_valign_top)
672 num = LyXTabular::M_VALIGN_TOP;
673 else if (ob == cell_options_->radio_valign_bottom)
674 num = LyXTabular::M_VALIGN_BOTTOM;
675 else if (ob == cell_options_->radio_valign_middle)
676 num = LyXTabular::M_VALIGN_MIDDLE;
678 return ButtonPolicy::SMI_VALID;
680 controller().set(num, special);
683 return ButtonPolicy::SMI_VALID;
687 int FormTabular::checkLongtableOptions(FL_OBJECT * ob, string & special)
689 bool flag = fl_get_button(ob);
690 if ((ob == longtable_options_->check_1head_2border_above) ||
691 (ob == longtable_options_->check_head_2border_above) ||
692 (ob == longtable_options_->check_foot_2border_above) ||
693 (ob == longtable_options_->check_lastfoot_2border_above)) {
694 special = "dl_above";
695 } else if ((ob == longtable_options_->check_1head_2border_below) ||
696 (ob == longtable_options_->check_head_2border_below) ||
697 (ob == longtable_options_->check_foot_2border_below) ||
698 (ob == longtable_options_->check_lastfoot_2border_below)) {
699 special = "dl_below";
700 } else if ((ob == longtable_options_->check_1head_empty) ||
701 (ob == longtable_options_->check_lastfoot_empty)) {
706 if ((ob == longtable_options_->check_lt_firsthead) ||
707 (ob == longtable_options_->check_1head_2border_above) ||
708 (ob == longtable_options_->check_1head_2border_below) ||
709 (ob == longtable_options_->check_1head_empty)) {
710 return (flag ? LyXTabular::SET_LTFIRSTHEAD :
711 LyXTabular::UNSET_LTFIRSTHEAD);
712 } else if ((ob == longtable_options_->check_lt_head) ||
713 (ob == longtable_options_->check_head_2border_above) ||
714 (ob == longtable_options_->check_head_2border_below)) {
715 return (flag ? LyXTabular::SET_LTHEAD : LyXTabular::UNSET_LTHEAD);
716 } else if ((ob == longtable_options_->check_lt_foot) ||
717 (ob == longtable_options_->check_foot_2border_above) ||
718 (ob == longtable_options_->check_foot_2border_below)) {
719 return (flag ? LyXTabular::SET_LTFOOT : LyXTabular::UNSET_LTFOOT);
720 } else if ((ob == longtable_options_->check_lt_lastfoot) ||
721 (ob == longtable_options_->check_lastfoot_2border_above) ||
722 (ob == longtable_options_->check_lastfoot_2border_below) ||
723 (ob == longtable_options_->check_lastfoot_empty)) {
724 return (flag ? LyXTabular::SET_LTLASTFOOT :
725 LyXTabular::UNSET_LTLASTFOOT);
728 return LyXTabular::LAST_ACTION;