- if (!inset_)
- return false;
-
- int s;
- LyXTabular::Feature num = LyXTabular::LAST_ACTION;
- string special;;
-
- int cell = inset_->getActCell();
-
- // 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;
- input(column_options_->input_column_width, 0);
- input(cell_options_->input_mcolumn_width, 0);
- input(column_options_->input_special_alignment, 0);
- input(cell_options_->input_special_multialign, 0);
- closing_ = false;
- ok();
- return true;
- }
-
- 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) ||
- (ob == column_options_->choice_value_column_width))
- {
- string const str =
- getLengthFromWidgets(column_options_->input_column_width,
- column_options_->choice_value_column_width);
- inset_->tabularFeatures(lv_->view(), LyXTabular::SET_PWIDTH, str);
-
- //check if the input is valid
- string const input =
- fl_get_input(column_options_->input_column_width);
- if (!input.empty() && !isValidLength(input) && !isStrDbl(input)) {
- fl_set_object_label(dialog_->text_warning,
- _("Warning: Invalid Length (valid example: 10mm)"));
- fl_show_object(dialog_->text_warning);
- return false;
+ 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;