- if (!inset_)
- return false;
-
- LyXTabular * tabular = inset_->tabular;
- int s;
- LyXTabular::Feature num = LyXTabular::LAST_ACTION;
- string special;;
-
- int cell = inset_->GetActCell();
- if (actCell_ != cell) {
- update();
- fl_set_object_label(dialog_->text_warning,
- _("Warning: Wrong Cursor position, updated window"));
- fl_show_object(dialog_->text_warning);
- return false;
- }
- // No point in processing directives that you can't do anything with
- // anyhow, so exit now if the buffer is read-only.
- if (lv_->buffer()->isReadonly()) {
- update();
- return false;
- }
- if (ob == column_options_->input_column_width) {
- string str = fl_get_input(ob);
- if (!str.empty() && !isValidLength(str)) {
- fl_set_object_label(dialog_->text_warning,
- _("Warning: Invalid Length (valid example: 10mm)"));
- fl_show_object(dialog_->text_warning);
- return false;
- }
- inset_->TabularFeatures(lv_->view(), LyXTabular::SET_PWIDTH,str);
- update(); // update for alignment
- return true;
- }
- if (ob == cell_options_->input_mcolumn_width) {
- string str = fl_get_input(ob);
- if (!str.empty() && !isValidLength(str)) {
- fl_set_object_label(dialog_->text_warning,
- _("Warning: Invalid Length (valid example: 10mm)"));
- fl_show_object(dialog_->text_warning);
- return false;
- }
- inset_->TabularFeatures(lv_->view(), LyXTabular::SET_MPWIDTH,str);
- update(); // update for alignment
- return true;
- }
- string str = fl_get_input(column_options_->input_column_width);
- if (!str.empty() && !isValidLength(str)) {
- fl_set_object_label(
- dialog_->text_warning,
- _("Warning: Invalid Length (valid example: 10mm)"));
- fl_show_object(dialog_->text_warning);
- return false;
- }
- if (ob == tabular_options_->button_append_row)
- num = LyXTabular::APPEND_ROW;
- else if (ob == tabular_options_->button_append_column)
- num = LyXTabular::APPEND_COLUMN;
- else if (ob == tabular_options_->button_delete_row)
- num = LyXTabular::DELETE_ROW;
- else if (ob == tabular_options_->button_delete_column)
- num = LyXTabular::DELETE_COLUMN;
- else if (ob == tabular_options_->button_set_borders)
- num = LyXTabular::SET_ALL_LINES;
- else if (ob == tabular_options_->button_unset_borders)
- num = LyXTabular::UNSET_ALL_LINES;
- else if (ob == column_options_->radio_border_top)
- num = LyXTabular::TOGGLE_LINE_TOP;
- else if (ob == column_options_->radio_border_bottom)
- num = LyXTabular::TOGGLE_LINE_BOTTOM;
- else if (ob == column_options_->radio_border_left)
- num = LyXTabular::TOGGLE_LINE_LEFT;
- else if (ob == column_options_->radio_border_right)
- num = LyXTabular::TOGGLE_LINE_RIGHT;
- else if (ob == column_options_->radio_align_left)
- num = LyXTabular::ALIGN_LEFT;
- else if (ob == column_options_->radio_align_right)
- num = LyXTabular::ALIGN_RIGHT;
- else if (ob == column_options_->radio_align_center)
- num = LyXTabular::ALIGN_CENTER;
- else if (ob == column_options_->radio_valign_top)
- num = LyXTabular::VALIGN_TOP;
- else if (ob == column_options_->radio_valign_bottom)
- num = LyXTabular::VALIGN_BOTTOM;
- else if (ob == column_options_->radio_valign_center)
- num = LyXTabular::VALIGN_CENTER;
- else if (ob == cell_options_->radio_multicolumn)
- num = LyXTabular::MULTICOLUMN;
- else if (ob == tabular_options_->radio_longtable) {
- bool const enable =
- fl_get_button(tabular_options_->radio_longtable);
-
- setEnabled(longtable_options_->radio_lt_firsthead, enable);
- setEnabled(longtable_options_->radio_lt_head, enable);
- setEnabled(longtable_options_->radio_lt_foot, enable);
- setEnabled(longtable_options_->radio_lt_lastfoot, enable);
- setEnabled(longtable_options_->radio_lt_newpage, enable);
-
- if (enable) {
- num = LyXTabular::SET_LONGTABULAR;
- int dummy;
- fl_set_button(longtable_options_->radio_lt_firsthead,
- tabular->GetRowOfLTFirstHead(cell, dummy));
- fl_set_button(longtable_options_->radio_lt_head,
- tabular->GetRowOfLTHead(cell, dummy));
- fl_set_button(longtable_options_->radio_lt_foot,
- tabular->GetRowOfLTFoot(cell, dummy));
- fl_set_button(longtable_options_->radio_lt_lastfoot,
- tabular->GetRowOfLTLastFoot(cell, dummy));
- fl_set_button(longtable_options_->radio_lt_firsthead,
- tabular->GetLTNewPage(cell));
- } else {
- num = LyXTabular::UNSET_LONGTABULAR;
- fl_set_button(longtable_options_->radio_lt_firsthead,0);
- fl_set_button(longtable_options_->radio_lt_head,0);
- fl_set_button(longtable_options_->radio_lt_foot,0);
- fl_set_button(longtable_options_->radio_lt_lastfoot,0);
- fl_set_button(longtable_options_->radio_lt_newpage,0);
- }
- } else if (ob == tabular_options_->radio_rotate_tabular) {
- s = fl_get_button(tabular_options_->radio_rotate_tabular);
- if (s)
- num = LyXTabular::SET_ROTATE_TABULAR;
- else
- num = LyXTabular::UNSET_ROTATE_TABULAR;
- } else if (ob == cell_options_->radio_rotate_cell) {
- s = fl_get_button(cell_options_->radio_rotate_cell);
- if (s)
- num = LyXTabular::SET_ROTATE_CELL;
+ int s;
+ LyXTabular::Feature num = LyXTabular::LAST_ACTION;
+ string special;
+
+ LyXTabular const & tabular = controller().tabular();
+
+ LyXTabular::idx_type const cell = controller().getActiveCell();
+
+ // ugly hack to auto-apply the stuff that hasn't been
+ // yet. don't let this continue to exist ...
+ if (ob == dialog_->button_close) {
+ closing_ = true;
+ string w1 =
+ getLengthFromWidgets(column_options_->input_column_width,
+ column_options_->choice_value_column_width);
+ string w2;
+ LyXLength llen = tabular.getColumnPWidth(cell);
+ if (!llen.zero())
+ w2 = llen.asString();
+
+ string mw1 = getLengthFromWidgets(cell_options_->input_mcolumn_width,
+ cell_options_->choice_value_mcolumn_width);
+ llen = tabular.getMColumnPWidth(cell);
+ string mw2;
+ if (llen.zero())
+ mw2 = "";
+ else
+ mw2 = llen.asString();
+
+ string al1 = getString(column_options_->input_special_alignment);
+ string al2 = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
+ string mal1 = getString(cell_options_->input_special_multialign);
+ string mal2 = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
+
+ // we must do these all at the end
+ if (w1 != w2)
+ input(column_options_->input_column_width, 0);
+ if (mw1 != mw2)
+ input(cell_options_->input_mcolumn_width, 0);
+ if (al1 != al2)
+ input(column_options_->input_special_alignment, 0);
+ if (mal1 != mal2)
+ input(cell_options_->input_special_multialign, 0);
+ closing_ = false;
+ dialog().OKButton();
+ return ButtonPolicy::SMI_VALID;
+ }
+
+ if (actCell_ != cell) {
+ update();
+ postWarning(_("Wrong Cursor position, updated window"));
+ return ButtonPolicy::SMI_VALID;
+ }
+
+ // No point in processing directives that you can't do anything with
+ // anyhow, so exit now if the buffer is read-only.
+ if (bc().bp().isReadOnly()) {
+ update();
+ return ButtonPolicy::SMI_VALID;
+ }
+
+ if ((ob == column_options_->input_column_width) ||
+ (ob == column_options_->choice_value_column_width)) {
+ string const str =
+ getLengthFromWidgets(column_options_->input_column_width,
+ column_options_->choice_value_column_width);
+ controller().set(LyXTabular::SET_PWIDTH, str);
+
+ //check if the input is valid
+ string const input = getString(column_options_->input_column_width);
+ if (!input.empty() && !isValidLength(input) && !isStrDbl(input)) {
+ postWarning(_("Invalid Length (valid example: 10mm)"));
+ return ButtonPolicy::SMI_INVALID;
+ }
+
+ update(); // update for alignment
+ return ButtonPolicy::SMI_VALID;
+ }
+
+ if ((ob == cell_options_->input_mcolumn_width) ||
+ (ob == cell_options_->choice_value_mcolumn_width)) {
+ string const str =
+ getLengthFromWidgets(cell_options_->input_mcolumn_width,
+ cell_options_->choice_value_mcolumn_width);
+ controller().set(LyXTabular::SET_MPWIDTH, str);
+
+ //check if the input is valid
+ string const input = getString(cell_options_->input_mcolumn_width);
+ if (!input.empty() && !isValidLength(input) && !isStrDbl(input)) {
+ postWarning(_("Invalid Length (valid example: 10mm)"));
+ return ButtonPolicy::SMI_INVALID;
+ }
+ update(); // update for alignment
+ return ButtonPolicy::SMI_VALID;
+ }
+
+ if (ob == tabular_options_->button_append_row)
+ num = LyXTabular::APPEND_ROW;
+ else if (ob == tabular_options_->button_append_column)
+ num = LyXTabular::APPEND_COLUMN;
+ else if (ob == tabular_options_->button_delete_row)
+ num = LyXTabular::DELETE_ROW;
+ else if (ob == tabular_options_->button_delete_column)
+ num = LyXTabular::DELETE_COLUMN;
+ else if (ob == tabular_options_->button_set_borders)
+ num = LyXTabular::SET_ALL_LINES;
+ else if (ob == tabular_options_->button_unset_borders)
+ num = LyXTabular::UNSET_ALL_LINES;
+ else if (ob == column_options_->check_border_top)
+ num = LyXTabular::TOGGLE_LINE_TOP;
+ else if (ob == column_options_->check_border_bottom)
+ num = LyXTabular::TOGGLE_LINE_BOTTOM;
+ else if (ob == column_options_->check_border_left)
+ num = LyXTabular::TOGGLE_LINE_LEFT;
+ else if (ob == column_options_->check_border_right)
+ num = LyXTabular::TOGGLE_LINE_RIGHT;
+ else if (ob == column_options_->radio_align_left)
+ num = LyXTabular::ALIGN_LEFT;
+ else if (ob == column_options_->radio_align_right)
+ num = LyXTabular::ALIGN_RIGHT;
+ else if (ob == column_options_->radio_align_center)
+ num = LyXTabular::ALIGN_CENTER;
+ else if (ob == column_options_->radio_align_block)
+ num = LyXTabular::ALIGN_BLOCK;
+ else if (ob == column_options_->radio_valign_top)
+ num = LyXTabular::VALIGN_TOP;
+ else if (ob == column_options_->radio_valign_bottom)
+ num = LyXTabular::VALIGN_BOTTOM;
+ else if (ob == column_options_->radio_valign_middle)
+ num = LyXTabular::VALIGN_MIDDLE;
+ else if (ob == cell_options_->check_multicolumn)
+ num = LyXTabular::MULTICOLUMN;
+ else if (ob == tabular_options_->check_longtable) {
+ if (fl_get_button(tabular_options_->check_longtable))
+ num = LyXTabular::SET_LONGTABULAR;
+ else
+ num = LyXTabular::UNSET_LONGTABULAR;
+ } else if (ob == tabular_options_->check_rotate_tabular) {
+ s = fl_get_button(tabular_options_->check_rotate_tabular);
+ if (s)
+ num = LyXTabular::SET_ROTATE_TABULAR;
+ else
+ num = LyXTabular::UNSET_ROTATE_TABULAR;
+ } else if (ob == cell_options_->check_rotate_cell) {
+ s = fl_get_button(cell_options_->check_rotate_cell);
+ if (s)
+ num = LyXTabular::SET_ROTATE_CELL;
+ else
+ num = LyXTabular::UNSET_ROTATE_CELL;
+ } else if (ob == cell_options_->check_useminipage) {
+ num = LyXTabular::SET_USEBOX;
+ special = "2";
+ } else if ((ob == longtable_options_->check_lt_firsthead) ||
+ (ob == longtable_options_->check_1head_2border_above) ||
+ (ob == longtable_options_->check_1head_2border_below) ||
+ (ob == longtable_options_->check_1head_empty) ||
+ (ob == longtable_options_->check_lt_head) ||
+ (ob == longtable_options_->check_head_2border_above) ||
+ (ob == longtable_options_->check_head_2border_below) ||
+ (ob == longtable_options_->check_lt_foot) ||
+ (ob == longtable_options_->check_foot_2border_above) ||
+ (ob == longtable_options_->check_foot_2border_below) ||
+ (ob == longtable_options_->check_lt_lastfoot) ||
+ (ob == longtable_options_->check_lastfoot_2border_above) ||
+ (ob == longtable_options_->check_lastfoot_2border_below) ||
+ (ob == longtable_options_->check_lastfoot_empty)) {
+ num = static_cast<LyXTabular::Feature>(checkLongtableOptions(ob, special));
+ } else if (ob == longtable_options_->check_lt_newpage) {
+ num = LyXTabular::SET_LTNEWPAGE;
+ } else if (ob == column_options_->input_special_alignment) {
+ special = getString(column_options_->input_special_alignment);
+ num = LyXTabular::SET_SPECIAL_COLUMN;
+ } else if (ob == cell_options_->input_special_multialign) {
+ special = getString(cell_options_->input_special_multialign);
+ num = LyXTabular::SET_SPECIAL_MULTI;
+ } else if (ob == cell_options_->check_border_top)
+ num = LyXTabular::M_TOGGLE_LINE_TOP;
+ else if (ob == cell_options_->check_border_bottom)
+ num = LyXTabular::M_TOGGLE_LINE_BOTTOM;
+ else if (ob == cell_options_->check_border_left)
+ num = LyXTabular::M_TOGGLE_LINE_LEFT;
+ else if (ob == cell_options_->check_border_right)
+ num = LyXTabular::M_TOGGLE_LINE_RIGHT;
+ else if (ob == cell_options_->radio_align_left)
+ num = LyXTabular::M_ALIGN_LEFT;
+ else if (ob == cell_options_->radio_align_right)
+ num = LyXTabular::M_ALIGN_RIGHT;
+ else if (ob == cell_options_->radio_align_center)
+ num = LyXTabular::M_ALIGN_CENTER;
+ else if (ob == cell_options_->radio_valign_top)
+ num = LyXTabular::M_VALIGN_TOP;
+ else if (ob == cell_options_->radio_valign_bottom)
+ num = LyXTabular::M_VALIGN_BOTTOM;
+ else if (ob == cell_options_->radio_valign_middle)
+ num = LyXTabular::M_VALIGN_MIDDLE;