*
* \author Jürgen Vigna
*
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
*/
#include <config.h>
-
-#include <vector>
-#include <algorithm>
-
-#include "ControlTabular.h"
-#include "xformsBC.h"
-#include "ButtonController.h"
-#include "insets/insettabular.h"
-
#include "FormTabular.h"
+#include "ControlTabular.h"
#include "forms/form_tabular.h"
-#include "debug.h"
+
#include "xforms_helpers.h"
-#include "gettext.h"
-#include "lyxrc.h"
-#include "helper_funcs.h"
-#include "input_validators.h"
+#include "xformsBC.h"
+
+#include "controllers/ButtonController.h"
+#include "controllers/helper_funcs.h"
+
#include "support/lstrings.h"
-#include FORMS_H_LOCATION
+#include "lyx_forms.h"
+
+using lyx::support::contains_functor;
+using lyx::support::getStringFromVector;
+using lyx::support::isStrDbl;
-using std::vector;
using std::bind2nd;
+using std::string;
+using std::vector;
namespace {
typedef FormController<ControlTabular, FormView<FD_tabular> > base_class;
FormTabular::FormTabular(Dialog & parent)
- : base_class(parent, _("Edit table settings"), scalableTabfolders),
+ : base_class(parent, _("Table Settings"), scalableTabfolders),
closing_(false), actCell_(-1)
{
}
fl_set_tabfolder_autofit(dialog_->tabfolder, FL_FIT);
// Stack tabs
- fl_addto_tabfolder(dialog_->tabfolder, _("Tabular"),
+ fl_addto_tabfolder(dialog_->tabfolder, _("Table").c_str(),
tabular_options_->form);
- fl_addto_tabfolder(dialog_->tabfolder, _("Column/Row"),
+ fl_addto_tabfolder(dialog_->tabfolder, _("Column/Row").c_str(),
column_options_->form);
- fl_addto_tabfolder(dialog_->tabfolder, _("Cell"),
+ fl_addto_tabfolder(dialog_->tabfolder, _("Cell").c_str(),
cell_options_->form);
- fl_addto_tabfolder(dialog_->tabfolder, _("LongTable"),
+ fl_addto_tabfolder(dialog_->tabfolder, _("LongTable").c_str(),
longtable_options_->form);
// FIXME: addReadOnly everything
sprintf(buf, "%d", row + 1);
fl_set_input(dialog_->input_tabular_row, buf);
fl_deactivate_object(dialog_->input_tabular_row);
- if (tabular.IsMultiColumn(cell)) {
+ if (tabular.isMultiColumn(cell)) {
fl_set_button(cell_options_->check_multicolumn, 1);
fl_set_button(cell_options_->check_border_top,
- tabular.TopLine(cell)?1:0);
+ tabular.topLine(cell)?1:0);
setEnabled(cell_options_->check_border_top, true);
fl_set_button(cell_options_->check_border_bottom,
- tabular.BottomLine(cell)?1:0);
+ tabular.bottomLine(cell)?1:0);
setEnabled(cell_options_->check_border_bottom, true);
// pay attention to left/right lines they are only allowed
// to set if we are in first/last cell of row or if the left/right
// cell is also a multicolumn.
- if (tabular.IsFirstCellInRow(cell) ||
- tabular.IsMultiColumn(cell-1)) {
+ if (tabular.isFirstCellInRow(cell) ||
+ tabular.isMultiColumn(cell-1)) {
fl_set_button(cell_options_->check_border_left,
- tabular.LeftLine(cell)?1:0);
+ tabular.leftLine(cell)?1:0);
setEnabled(cell_options_->check_border_left, true);
} else {
fl_set_button(cell_options_->check_border_left, 0);
setEnabled(cell_options_->check_border_left, false);
}
- if (tabular.IsLastCellInRow(cell) ||
- tabular.IsMultiColumn(cell+1)) {
+ if (tabular.isLastCellInRow(cell) ||
+ tabular.isMultiColumn(cell+1)) {
fl_set_button(cell_options_->check_border_right,
- tabular.RightLine(cell)?1:0);
+ tabular.rightLine(cell)?1:0);
setEnabled(cell_options_->check_border_right, true);
} else {
fl_set_button(cell_options_->check_border_right, 0);
setEnabled(cell_options_->check_border_right, false);
}
- pwidth = tabular.GetMColumnPWidth(cell);
- align = tabular.GetAlignment(cell);
+ pwidth = tabular.getMColumnPWidth(cell);
+ align = tabular.getAlignment(cell);
// set the horiz. alignment, default is left here
fl_set_button(cell_options_->radio_align_left, 0);
fl_set_button(cell_options_->radio_align_right, 0);
else
fl_set_button(cell_options_->radio_align_left, 1);
- align = tabular.GetVAlignment(cell);
+ align = tabular.getVAlignment(cell);
fl_set_button(cell_options_->radio_valign_top, 0);
fl_set_button(cell_options_->radio_valign_bottom, 0);
- fl_set_button(cell_options_->radio_valign_center, 0);
- if (pwidth.zero() || (align == LyXTabular::LYX_VALIGN_CENTER))
- fl_set_button(cell_options_->radio_valign_center, 1);
+ fl_set_button(cell_options_->radio_valign_middle, 0);
+ if (pwidth.zero() || (align == LyXTabular::LYX_VALIGN_MIDDLE))
+ fl_set_button(cell_options_->radio_valign_middle, 1);
else if (align == LyXTabular::LYX_VALIGN_BOTTOM)
fl_set_button(cell_options_->radio_valign_bottom, 1);
else
fl_set_button(cell_options_->radio_valign_top, 1);
- special = tabular.GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
+ special = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
fl_set_input(cell_options_->input_special_multialign, special.c_str());
bool const metric(controller().useMetricUnits());
string const default_unit = metric ? "cm" : "in";
setEnabled(cell_options_->radio_valign_top, !pwidth.zero());
setEnabled(cell_options_->radio_valign_bottom, !pwidth.zero());
- setEnabled(cell_options_->radio_valign_center, !pwidth.zero());
+ setEnabled(cell_options_->radio_valign_middle, !pwidth.zero());
setEnabled(cell_options_->radio_align_left, true);
setEnabled(cell_options_->radio_align_right, true);
fl_set_button(cell_options_->radio_valign_bottom, 0);
setEnabled(cell_options_->radio_valign_bottom, false);
- fl_set_button(cell_options_->radio_valign_center, 0);
- setEnabled(cell_options_->radio_valign_center, false);
+ fl_set_button(cell_options_->radio_valign_middle, 0);
+ setEnabled(cell_options_->radio_valign_middle, false);
fl_set_input(cell_options_->input_special_multialign, "");
setEnabled(cell_options_->input_special_multialign, false);
setEnabled(cell_options_->input_mcolumn_width, false);
setEnabled(cell_options_->choice_value_mcolumn_width, false);
}
- if (tabular.GetRotateCell(cell))
+ if (tabular.getRotateCell(cell))
fl_set_button(cell_options_->check_rotate_cell, 1);
else
fl_set_button(cell_options_->check_rotate_cell, 0);
- if (tabular.TopLine(cell, true))
+ if (tabular.topLine(cell, true))
fl_set_button(column_options_->check_border_top, 1);
else
fl_set_button(column_options_->check_border_top, 0);
- if (tabular.BottomLine(cell, true))
+ if (tabular.bottomLine(cell, true))
fl_set_button(column_options_->check_border_bottom, 1);
else
fl_set_button(column_options_->check_border_bottom, 0);
- if (tabular.LeftLine(cell, true))
+ if (tabular.leftLine(cell, true))
fl_set_button(column_options_->check_border_left, 1);
else
fl_set_button(column_options_->check_border_left, 0);
- if (tabular.RightLine(cell, true))
+ if (tabular.rightLine(cell, true))
fl_set_button(column_options_->check_border_right, 1);
else
fl_set_button(column_options_->check_border_right, 0);
- special = tabular.GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
+ special = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
fl_set_input(column_options_->input_special_alignment, special.c_str());
bool const isReadonly = bc().bp().isReadOnly();
setEnabled(column_options_->input_special_alignment, !isReadonly);
- pwidth = tabular.GetColumnPWidth(cell);
+ pwidth = tabular.getColumnPWidth(cell);
bool const metric = controller().useMetricUnits();
string const default_unit = metric ? "cm" : "in";
updateWidgetsFromLength(column_options_->input_column_width,
setEnabled(cell_options_->check_useminipage, !pwidth.zero());
if (!pwidth.zero()) {
- if (tabular.GetUsebox(cell) == 2)
+ if (tabular.getUsebox(cell) == 2)
fl_set_button(cell_options_->check_useminipage, 1);
else
fl_set_button(cell_options_->check_useminipage, 0);
} else {
fl_set_button(cell_options_->check_useminipage, 0);
}
- align = tabular.GetAlignment(cell, true);
+ align = tabular.getAlignment(cell, true);
fl_set_button(column_options_->radio_align_left, 0);
fl_set_button(column_options_->radio_align_right, 0);
fl_set_button(column_options_->radio_align_center, 0);
fl_set_button(column_options_->radio_align_center, 1);
else
fl_set_button(column_options_->radio_align_block, 1);
- align = tabular.GetVAlignment(cell, true);
+ align = tabular.getVAlignment(cell, true);
fl_set_button(column_options_->radio_valign_top, 0);
fl_set_button(column_options_->radio_valign_bottom, 0);
- fl_set_button(column_options_->radio_valign_center, 0);
- if (pwidth.zero() || (align == LyXTabular::LYX_VALIGN_CENTER))
- fl_set_button(column_options_->radio_valign_center, 1);
+ fl_set_button(column_options_->radio_valign_middle, 0);
+ if (pwidth.zero() || (align == LyXTabular::LYX_VALIGN_MIDDLE))
+ fl_set_button(column_options_->radio_valign_middle, 1);
else if (align == LyXTabular::LYX_VALIGN_BOTTOM)
fl_set_button(column_options_->radio_valign_bottom, 1);
else
setEnabled(column_options_->radio_align_block, !pwidth.zero());
setEnabled(column_options_->radio_valign_top, !pwidth.zero());
setEnabled(column_options_->radio_valign_bottom, !pwidth.zero());
- setEnabled(column_options_->radio_valign_center, !pwidth.zero());
+ setEnabled(column_options_->radio_valign_middle, !pwidth.zero());
fl_set_button(tabular_options_->check_longtable,
- tabular.IsLongTabular());
+ tabular.isLongTabular());
- bool const enable = tabular.IsLongTabular();
+ bool const enable = tabular.isLongTabular();
setEnabled(longtable_options_->check_lt_firsthead, enable);
setEnabled(longtable_options_->check_1head_2border_above, enable);
if (enable) {
LyXTabular::ltType ltt;
bool use_empty;
- bool row_set = tabular.GetRowOfLTHead(row, ltt);
+ bool row_set = tabular.getRowOfLTHead(row, ltt);
fl_set_button(longtable_options_->check_lt_head, row_set);
if (ltt.set) {
fl_set_button(longtable_options_->check_head_2border_above,
use_empty = false;
}
//
- row_set = tabular.GetRowOfLTFirstHead(row, ltt);
+ row_set = tabular.getRowOfLTFirstHead(row, ltt);
fl_set_button(longtable_options_->check_lt_firsthead, row_set);
if (ltt.set && (!ltt.empty || !use_empty)) {
fl_set_button(longtable_options_->check_1head_2border_above,
}
}
//
- row_set = tabular.GetRowOfLTFoot(row, ltt);
+ row_set = tabular.getRowOfLTFoot(row, ltt);
fl_set_button(longtable_options_->check_lt_foot, row_set);
if (ltt.set) {
fl_set_button(longtable_options_->check_foot_2border_above,
use_empty = false;
}
//
- row_set = tabular.GetRowOfLTLastFoot(row, ltt);
+ row_set = tabular.getRowOfLTLastFoot(row, ltt);
fl_set_button(longtable_options_->check_lt_lastfoot, row_set);
if (ltt.set && (!ltt.empty || !use_empty)) {
fl_set_button(longtable_options_->check_lastfoot_2border_above,
}
}
fl_set_button(longtable_options_->check_lt_newpage,
- tabular.GetLTNewPage(row));
+ tabular.getLTNewPage(row));
} else {
fl_set_button(longtable_options_->check_lt_firsthead, 0);
fl_set_button(longtable_options_->check_1head_2border_above, 0);
fl_set_button(longtable_options_->check_lt_newpage, 0);
}
fl_set_button(tabular_options_->check_rotate_tabular,
- tabular.GetRotateTabular());
+ tabular.getRotateTabular());
}
// yet. don't let this continue to exist ...
if (ob == dialog_->button_close) {
closing_ = true;
- string str1 =
+ string w1 =
getLengthFromWidgets(column_options_->input_column_width,
column_options_->choice_value_column_width);
- string str2;
- LyXLength llen = tabular.GetColumnPWidth(cell);
+ string w2;
+ LyXLength llen = tabular.getColumnPWidth(cell);
if (!llen.zero())
- str2 = llen.asString();
- if (str1 != str2)
- input(column_options_->input_column_width, 0);
- str1 = getLengthFromWidgets(cell_options_->input_mcolumn_width,
+ w2 = llen.asString();
+
+ string mw1 = getLengthFromWidgets(cell_options_->input_mcolumn_width,
cell_options_->choice_value_mcolumn_width);
- llen = tabular.GetMColumnPWidth(cell);
+ llen = tabular.getMColumnPWidth(cell);
+ string mw2;
if (llen.zero())
- str2 = "";
+ mw2 = "";
else
- str2 = llen.asString();
- if (str1 != str2)
+ 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);
- str1 = getString(column_options_->input_special_alignment);
- str2 = tabular.GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
- if (str1 != str2)
+ if (al1 != al2)
input(column_options_->input_special_alignment, 0);
- str1 = getString(cell_options_->input_special_multialign);
- str2 = tabular.GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
- if (str1 != str2)
+ if (mal1 != mal2)
input(cell_options_->input_special_multialign, 0);
-
closing_ = false;
dialog().OKButton();
return ButtonPolicy::SMI_VALID;
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 == 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) {
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_center)
- num = LyXTabular::M_VALIGN_CENTER;
+ else if (ob == cell_options_->radio_valign_middle)
+ num = LyXTabular::M_VALIGN_MIDDLE;
else
return ButtonPolicy::SMI_VALID;