-/* FormTabular.C
- * FormTabular Interface Class Implementation
+/**
+ * \file FormTabular.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Jürgen Vigna
+ *
+ * Full author contact details are available in file CREDITS.
*/
#include <config.h>
-#include "lyx_gui_misc.h"
-#include "gettext.h"
-#include FORMS_H_LOCATION
#include "FormTabular.h"
-#include "form_tabular.h"
-#include "xform_macros.h"
-#include "input_validators.h"
-#include "LyXView.h"
-#include "lyxfunc.h"
-#include "Dialogs.h"
-#include "lyxrc.h"
-#include "debug.h"
-#include "insets/insettabular.h"
-#include "buffer.h"
-
-
-#ifdef SIGC_CXX_NAMESPACES
-using SigC::slot;
+#include "ControlTabular.h"
+#include "forms/form_tabular.h"
+
+#include "xforms_helpers.h"
+#include "xformsBC.h"
+
+#include "controllers/ButtonController.h"
+#include "controllers/helper_funcs.h"
+
+#include "support/lstrings.h"
+
+#include "lyx_forms.h"
+
+using lyx::support::contains_functor;
+using lyx::support::getStringFromVector;
+using lyx::support::isStrDbl;
+
+using std::bind2nd;
+using std::string;
+using std::vector;
+
+
+namespace {
+
+#if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL < 2)
+bool const scalableTabfolders = false;
+#else
+bool const scalableTabfolders = true;
#endif
-C_RETURNCB(FormTabular, WMHideCB)
-C_GENERICCB(FormTabular, CloseCB)
-C_GENERICCB(FormTabular, InputCB)
-C_GENERICCB(FormTabular, OKCB)
-C_GENERICCB(FormTabular, ApplyCB)
-C_GENERICCB(FormTabular, CancelCB)
+} // namespace anon
-FormTabular::FormTabular(LyXView * lv, Dialogs * d)
- : dialog_(0), tabular_options_(0), column_options_(0),
- cell_options_(0), longtable_options_(0), create_tabular_(0),
- lv_(lv), d_(d), u_(0), h_(0), inset_(0), actCell_(-1)
+typedef FormController<ControlTabular, FormView<FD_tabular> > base_class;
+
+FormTabular::FormTabular(Dialog & parent)
+ : base_class(parent, _("Table Settings"), scalableTabfolders),
+ closing_(false), actCell_(-1)
{
- // let the dialog be shown
- // This is a permanent connection so we won't bother
- // storing a copy because we won't be disconnecting.
- d->showTabular.connect(slot(this, &FormTabular::showInset));
- d->updateTabular.connect(slot(this, &FormTabular::updateInset));
- d->hideTabular.connect(slot(this, &FormTabular::hideInset));
- d->showTabularCreate.connect(slot(this, &FormTabular::show_create));
}
-FormTabular::~FormTabular()
+void FormTabular::redraw()
{
- // we don't need to disconnect u and h here because
- // their destructors do that.
- delete dialog_;
- delete tabular_options_;
- delete column_options_;
- delete cell_options_;
- delete longtable_options_;
- delete create_tabular_;
+ if (form() && form()->visible)
+ fl_redraw_form(form());
+ else
+ return;
+
+ FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder);
+ if (outer_form && outer_form->visible)
+ fl_redraw_form(outer_form);
}
void FormTabular::build()
{
- dialog_ = build_tabular();
- tabular_options_ = build_tabular_options();
- column_options_ = build_column_options();
- cell_options_ = build_cell_options();
- longtable_options_ = build_longtable_options();
- create_tabular_ = build_create_tabular();
-
- fl_set_input_return(column_options_->input_column_width,
- FL_RETURN_END);
- fl_set_input_return(column_options_->input_special_alignment,
- FL_RETURN_CHANGED);
- fl_set_input_return(cell_options_->input_mcolumn_width,
- FL_RETURN_CHANGED);
- fl_set_input_return(cell_options_->input_special_multialign,
- FL_RETURN_CHANGED);
-
- fl_addto_tabfolder(dialog_->tabFolder, _("Tabular"),
- tabular_options_->form);
- fl_addto_tabfolder(dialog_->tabFolder, _("Column/Row"),
- column_options_->form);
- fl_addto_tabfolder(dialog_->tabFolder, _("Cell"),
- cell_options_->form);
- fl_addto_tabfolder(dialog_->tabFolder, _("LongTable"),
- longtable_options_->form);
-
- fl_set_form_atclose(dialog_->form,
- C_FormTabularWMHideCB, 0);
-
- fl_set_slider_bounds(create_tabular_->slider_rows, 1, 50);
- fl_set_slider_bounds(create_tabular_->slider_columns, 1, 50);
- fl_set_slider_value(create_tabular_->slider_rows, 5);
- fl_set_slider_value(create_tabular_->slider_columns, 5);
- fl_set_slider_precision(create_tabular_->slider_rows, 0);
- fl_set_slider_precision(create_tabular_->slider_columns, 0);
- fl_set_form_atclose(create_tabular_->form,
- C_FormTabularWMHideCB, 0);
-}
+ dialog_.reset(build_tabular(this));
+ // Allow the base class to control messages
+ setMessageWidget(dialog_->text_warning);
-void FormTabular::show()
-{
- if (!dialog_) {
- build();
- }
- update(); // make sure its up-to-date
-
- if (dialog_->form->visible) {
- fl_raise_form(dialog_->form);
- } else {
- fl_show_form(dialog_->form,
- FL_PLACE_MOUSE | FL_FREE_SIZE,
- FL_TRANSIENT,
- _("Tabular Layout"));
-// u_ = d_->updateBufferDependent.connect(slot(this,
-// &FormTabular::update));
- h_ = d_->hideBufferDependent.connect(slot(this,
- &FormTabular::hide));
- }
-}
+ // trigger an input event for cut&paste with middle mouse button.
+ setPrehandler(dialog_->input_tabular_column);
+ setPrehandler(dialog_->input_tabular_row);
-void FormTabular::showInset(InsetTabular * ti)
-{
- inset_ = ti;
- if (ti) {
- show();
- }
-}
+ // Create the contents of the unit choices; don't include the "%" terms.
+ vector<string> units_vec = getLatexUnits();
+ vector<string>::iterator ret =
+ remove_if(units_vec.begin(), units_vec.end(),
+ bind2nd(contains_functor(), "%"));
+ units_vec.erase(ret, units_vec.end());
+ string const units = getStringFromVector(units_vec, "|");
-void FormTabular::hide()
-{
- if (dialog_ && dialog_->form && dialog_->form->visible) {
- fl_hide_form(dialog_->form);
- u_.disconnect();
- h_.disconnect();
- inset_ = 0;
- }
-}
+ // tabular options form
+ tabular_options_.reset(build_tabular_options(this));
+ // column options form
+ column_options_.reset(build_tabular_column(this));
-void FormTabular::hideInset(InsetTabular * ti)
-{
- if (inset_ == ti) {
- inset_ = 0;
- hide();
- }
+ fl_set_input_return(column_options_->input_column_width,
+ FL_RETURN_END);
+ fl_set_input_return(column_options_->input_special_alignment,
+ FL_RETURN_END);
+
+ // trigger an input event for cut&paste with middle mouse button.
+ setPrehandler(column_options_->input_column_width);
+ setPrehandler(column_options_->input_special_alignment);
+
+ fl_addto_choice(column_options_->choice_value_column_width,
+ units.c_str());
+
+ // cell options form
+ cell_options_.reset(build_tabular_cell(this));
+
+ fl_set_input_return(cell_options_->input_mcolumn_width,
+ FL_RETURN_END);
+ fl_set_input_return(cell_options_->input_special_multialign,
+ FL_RETURN_END);
+
+ // trigger an input event for cut&paste with middle mouse button.
+ setPrehandler(cell_options_->input_mcolumn_width);
+ setPrehandler(cell_options_->input_special_multialign);
+
+ fl_addto_choice(cell_options_->choice_value_mcolumn_width,
+ units.c_str());
+
+ longtable_options_.reset(build_tabular_longtable(this));
+
+ // Enable the tabfolder to be rescaled correctly.
+ if (scalableTabfolders)
+ fl_set_tabfolder_autofit(dialog_->tabfolder, FL_FIT);
+
+ // Stack tabs
+ fl_addto_tabfolder(dialog_->tabfolder, _("Table").c_str(),
+ tabular_options_->form);
+ fl_addto_tabfolder(dialog_->tabfolder, _("Column/Row").c_str(),
+ column_options_->form);
+ fl_addto_tabfolder(dialog_->tabfolder, _("Cell").c_str(),
+ cell_options_->form);
+ fl_addto_tabfolder(dialog_->tabfolder, _("LongTable").c_str(),
+ longtable_options_->form);
+
+ // FIXME: addReadOnly everything
}
void FormTabular::update()
{
- if (dialog_) {
- local_update(true);
- }
-}
+ if (closing_)
+ return;
+
+ LyXTabular const & tabular = controller().tabular();
+
+ int align;
+ char buf[12];
+ LyXLength pwidth;
+ string special;
+
+ int const cell = controller().getActiveCell();
+ actCell_ = cell;
+ int column = tabular.column_of_cell(cell) + 1;
+ clearMessage();
+ fl_activate_object(column_options_->input_special_alignment);
+ fl_activate_object(cell_options_->input_special_multialign);
+ fl_activate_object(column_options_->input_column_width);
+ fl_activate_object(column_options_->choice_value_column_width);
+ sprintf(buf, "%d", column);
+ fl_set_input(dialog_->input_tabular_column, buf);
+ fl_deactivate_object(dialog_->input_tabular_column);
+ int row = tabular.row_of_cell(cell);
+ sprintf(buf, "%d", row + 1);
+ fl_set_input(dialog_->input_tabular_row, buf);
+ fl_deactivate_object(dialog_->input_tabular_row);
+ 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);
+ setEnabled(cell_options_->check_border_top, true);
+ fl_set_button(cell_options_->check_border_bottom,
+ 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)) {
+ fl_set_button(cell_options_->check_border_left,
+ 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)) {
+ fl_set_button(cell_options_->check_border_right,
+ 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);
+ // 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);
+ fl_set_button(cell_options_->radio_align_center, 0);
+ if (align == LYX_ALIGN_RIGHT)
+ fl_set_button(cell_options_->radio_align_right, 1);
+ else if (align == LYX_ALIGN_CENTER)
+ fl_set_button(cell_options_->radio_align_center, 1);
+ else
+ fl_set_button(cell_options_->radio_align_left, 1);
+
+ 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_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);
+ fl_set_input(cell_options_->input_special_multialign, special.c_str());
+ bool const metric(controller().useMetricUnits());
+ string const default_unit = metric ? "cm" : "in";
+ updateWidgetsFromLength(cell_options_->input_mcolumn_width,
+ cell_options_->choice_value_mcolumn_width,
+ pwidth, default_unit);
+
+ if (!bc().bp().isReadOnly()) {
+ setEnabled(cell_options_->input_special_multialign, true);
+ setEnabled(cell_options_->input_mcolumn_width, true);
+ setEnabled(cell_options_->choice_value_mcolumn_width, true);
+ }
+
+ setEnabled(cell_options_->radio_valign_top, !pwidth.zero());
+ setEnabled(cell_options_->radio_valign_bottom, !pwidth.zero());
+ setEnabled(cell_options_->radio_valign_middle, !pwidth.zero());
+
+ setEnabled(cell_options_->radio_align_left, true);
+ setEnabled(cell_options_->radio_align_right, true);
+ setEnabled(cell_options_->radio_align_center, true);
+ } else {
+ fl_set_button(cell_options_->check_multicolumn, 0);
-void FormTabular::updateInset(InsetTabular * ti)
-{
- inset_ = ti;
- if (ti && dialog_ && dialog_->form->visible) {
- update();
- }
-}
+ fl_set_button(cell_options_->check_border_top, 0);
+ setEnabled(cell_options_->check_border_top, false);
+ fl_set_button(cell_options_->check_border_bottom, 0);
+ setEnabled(cell_options_->check_border_bottom, false);
-int FormTabular::WMHideCB(FL_FORM * form, void *)
-{
- // Ensure that the signals (u and h) are disconnected even if the
- // window manager is used to close the dialog.
- FormTabular * pre = static_cast<FormTabular*>(form->u_vdata);
- pre->hide();
- return FL_CANCEL;
-}
+ fl_set_button(cell_options_->check_border_left, 0);
+ setEnabled(cell_options_->check_border_left, false);
+ fl_set_button(cell_options_->check_border_right, 0);
+ setEnabled(cell_options_->check_border_right, false);
-void FormTabular::CloseCB(FL_OBJECT * ob, long)
-{
- FormTabular * pre = static_cast<FormTabular*>(ob->form->u_vdata);
- pre->hide();
-}
+ fl_set_button(cell_options_->radio_align_left, 0);
+ setEnabled(cell_options_->radio_align_left, false);
+ fl_set_button(cell_options_->radio_align_right, 0);
+ setEnabled(cell_options_->radio_align_right, false);
-void FormTabular::InputCB(FL_OBJECT * ob, long l)
-{
- FormTabular * pre = static_cast<FormTabular*>(ob->form->u_vdata);
- pre->SetTabularOptions(ob, l);
-}
+ fl_set_button(cell_options_->radio_align_center, 0);
+ setEnabled(cell_options_->radio_align_center, false);
+ fl_set_button(cell_options_->radio_valign_top, 0);
+ setEnabled(cell_options_->radio_valign_top, false);
-bool FormTabular::local_update(bool)
-{
- if (!inset_ || !inset_->tabular)
- return false;
-
- LyXTabular
- * tabular = inset_->tabular;
- int
- align,
- cell,
- column,row;
- char
- buf[12];
- string
- pwidth, special;
-
- actCell_ = cell = inset_->GetActCell();
- column = tabular->column_of_cell(cell)+1;
- fl_set_object_label(dialog_->text_warning,"");
- fl_activate_object(column_options_->input_special_alignment);
- fl_activate_object(cell_options_->input_special_multialign);
- fl_activate_object(column_options_->input_column_width);
- sprintf(buf,"%d",column);
- fl_set_input(dialog_->input_tabular_column, buf);
- fl_deactivate_object(dialog_->input_tabular_column);
- row = tabular->row_of_cell(cell)+1;
- sprintf(buf,"%d",row);
- fl_set_input(dialog_->input_tabular_row, buf);
- fl_deactivate_object(dialog_->input_tabular_row);
- if (tabular->IsMultiColumn(cell)) {
- fl_set_button(cell_options_->radio_multicolumn, 1);
- fl_set_button(cell_options_->radio_border_top,
- tabular->TopLine(cell)?1:0);
- fl_activate_object(cell_options_->radio_border_top);
- fl_set_object_lcol(cell_options_->radio_border_top, FL_BLACK);
- fl_set_button(cell_options_->radio_border_bottom,
- tabular->BottomLine(cell)?1:0);
- fl_activate_object(cell_options_->radio_border_bottom);
- fl_set_object_lcol(cell_options_->radio_border_bottom, FL_BLACK);
- fl_set_button(cell_options_->radio_border_left,
- tabular->LeftLine(cell)?1:0);
- fl_activate_object(cell_options_->radio_border_left);
- fl_set_object_lcol(cell_options_->radio_border_left, FL_BLACK);
- fl_set_button(cell_options_->radio_border_right,
- tabular->RightLine(cell)?1:0);
- fl_activate_object(cell_options_->radio_border_right);
- fl_set_object_lcol(cell_options_->radio_border_right, FL_BLACK);
- pwidth = tabular->GetMColumnPWidth(cell);
- align = tabular->GetAlignment(cell);
- if (!pwidth.empty() || (align == LYX_ALIGN_LEFT))
- fl_set_button(cell_options_->radio_align_left, 1);
- else if (align == LYX_ALIGN_RIGHT)
- fl_set_button(cell_options_->radio_align_right, 1);
+ fl_set_button(cell_options_->radio_valign_bottom, 0);
+ setEnabled(cell_options_->radio_valign_bottom, 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);
+
+ fl_set_input(cell_options_->input_mcolumn_width, "");
+ setEnabled(cell_options_->input_mcolumn_width, false);
+ setEnabled(cell_options_->choice_value_mcolumn_width, false);
+ }
+ if (tabular.getRotateCell(cell))
+ fl_set_button(cell_options_->check_rotate_cell, 1);
else
- fl_set_button(cell_options_->radio_align_center, 1);
- fl_activate_object(cell_options_->radio_align_left);
- fl_set_object_lcol(cell_options_->radio_align_left, FL_BLACK);
- fl_activate_object(cell_options_->radio_align_right);
- fl_set_object_lcol(cell_options_->radio_align_right, FL_BLACK);
- fl_activate_object(cell_options_->radio_align_center);
- fl_set_object_lcol(cell_options_->radio_align_center, FL_BLACK);
- 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.empty() || (align == LyXTabular::LYX_VALIGN_CENTER))
- fl_set_button(cell_options_->radio_valign_center, 1);
- else if (align == LyXTabular::LYX_VALIGN_BOTTOM)
- fl_set_button(cell_options_->radio_valign_bottom, 1);
+ fl_set_button(cell_options_->check_rotate_cell, 0);
+ if (tabular.topLine(cell, true))
+ fl_set_button(column_options_->check_border_top, 1);
else
- fl_set_button(cell_options_->radio_valign_top, 1);
- fl_activate_object(cell_options_->radio_valign_top);
- fl_set_object_lcol(cell_options_->radio_valign_top, FL_BLACK);
- fl_activate_object(cell_options_->radio_valign_bottom);
- fl_set_object_lcol(cell_options_->radio_valign_bottom, FL_BLACK);
- fl_activate_object(cell_options_->radio_valign_center);
- fl_set_object_lcol(cell_options_->radio_valign_center, FL_BLACK);
- special = tabular->GetAlignSpecial(cell,LyXTabular::SET_SPECIAL_MULTI);
- fl_set_input(cell_options_->input_special_multialign, special.c_str());
- fl_set_input(cell_options_->input_mcolumn_width,pwidth.c_str());
- if (!lv_->buffer()->isReadonly()) {
- fl_activate_object(cell_options_->input_special_multialign);
- fl_set_object_lcol(cell_options_->input_special_multialign,
- FL_BLACK);
- fl_activate_object(cell_options_->input_mcolumn_width);
- fl_set_object_lcol(cell_options_->input_mcolumn_width, FL_BLACK);
- }
- if (!pwidth.empty()) {
- fl_deactivate_object(cell_options_->radio_align_left);
- fl_deactivate_object(cell_options_->radio_align_right);
- fl_deactivate_object(cell_options_->radio_align_center);
- fl_set_object_lcol(cell_options_->radio_align_left, FL_INACTIVE);
- fl_set_object_lcol(cell_options_->radio_align_right, FL_INACTIVE);
- fl_set_object_lcol(cell_options_->radio_align_center, FL_INACTIVE);
- fl_activate_object(cell_options_->radio_valign_top);
- fl_activate_object(cell_options_->radio_valign_bottom);
- fl_activate_object(cell_options_->radio_valign_center);
- fl_set_object_lcol(cell_options_->radio_valign_top, FL_BLACK);
- fl_set_object_lcol(cell_options_->radio_valign_bottom, FL_BLACK);
- fl_set_object_lcol(cell_options_->radio_valign_center, FL_BLACK);
+ fl_set_button(column_options_->check_border_top, 0);
+ 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))
+ fl_set_button(column_options_->check_border_left, 1);
+ else
+ fl_set_button(column_options_->check_border_left, 0);
+ 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);
+ 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);
+ bool const metric = controller().useMetricUnits();
+ string const default_unit = metric ? "cm" : "in";
+ updateWidgetsFromLength(column_options_->input_column_width,
+ column_options_->choice_value_column_width,
+ pwidth, default_unit);
+ setEnabled(column_options_->input_column_width, !isReadonly);
+ setEnabled(column_options_->choice_value_column_width, !isReadonly);
+
+ setEnabled(cell_options_->check_useminipage, !pwidth.zero());
+ if (!pwidth.zero()) {
+ if (tabular.getUsebox(cell) == 2)
+ fl_set_button(cell_options_->check_useminipage, 1);
+ else
+ fl_set_button(cell_options_->check_useminipage, 0);
} else {
- fl_activate_object(cell_options_->radio_align_left);
- fl_activate_object(cell_options_->radio_align_right);
- fl_activate_object(cell_options_->radio_align_center);
- fl_set_object_lcol(cell_options_->radio_align_left, FL_BLACK);
- fl_set_object_lcol(cell_options_->radio_align_right, FL_BLACK);
- fl_set_object_lcol(cell_options_->radio_align_center, FL_BLACK);
- fl_deactivate_object(cell_options_->radio_valign_top);
- fl_deactivate_object(cell_options_->radio_valign_bottom);
- fl_deactivate_object(cell_options_->radio_valign_center);
- fl_set_object_lcol(cell_options_->radio_valign_top, FL_INACTIVE);
- fl_set_object_lcol(cell_options_->radio_valign_bottom,FL_INACTIVE);
- fl_set_object_lcol(cell_options_->radio_valign_center,FL_INACTIVE);
+ fl_set_button(cell_options_->check_useminipage, 0);
}
- } else {
- fl_set_button(cell_options_->radio_multicolumn, 0);
- fl_set_button(cell_options_->radio_border_top, 0);
- fl_deactivate_object(cell_options_->radio_border_top);
- fl_set_object_lcol(cell_options_->radio_border_top, FL_INACTIVE);
- fl_set_button(cell_options_->radio_border_bottom, 0);
- fl_deactivate_object(cell_options_->radio_border_bottom);
- fl_set_object_lcol(cell_options_->radio_border_bottom, FL_INACTIVE);
- fl_set_button(cell_options_->radio_border_left, 0);
- fl_deactivate_object(cell_options_->radio_border_left);
- fl_set_object_lcol(cell_options_->radio_border_left, FL_INACTIVE);
- fl_set_button(cell_options_->radio_border_right, 0);
- fl_deactivate_object(cell_options_->radio_border_right);
- fl_set_object_lcol(cell_options_->radio_border_right, FL_INACTIVE);
- fl_set_button(cell_options_->radio_align_left, 0);
- fl_deactivate_object(cell_options_->radio_align_left);
- fl_set_object_lcol(cell_options_->radio_align_left, FL_INACTIVE);
- fl_set_button(cell_options_->radio_align_right, 0);
- fl_deactivate_object(cell_options_->radio_align_right);
- fl_set_object_lcol(cell_options_->radio_align_right, FL_INACTIVE);
- fl_set_button(cell_options_->radio_align_center, 0);
- fl_deactivate_object(cell_options_->radio_align_center);
- fl_set_object_lcol(cell_options_->radio_align_center, FL_INACTIVE);
- fl_set_button(cell_options_->radio_valign_top, 0);
- fl_deactivate_object(cell_options_->radio_valign_top);
- fl_set_object_lcol(cell_options_->radio_valign_top, FL_INACTIVE);
- fl_set_button(cell_options_->radio_valign_bottom, 0);
- fl_deactivate_object(cell_options_->radio_valign_bottom);
- fl_set_object_lcol(cell_options_->radio_valign_bottom, FL_INACTIVE);
- fl_set_button(cell_options_->radio_valign_center, 0);
- fl_deactivate_object(cell_options_->radio_valign_center);
- fl_set_object_lcol(cell_options_->radio_valign_center, FL_INACTIVE);
- fl_set_input(cell_options_->input_special_multialign, "");
- fl_deactivate_object(cell_options_->input_special_multialign);
- fl_set_object_lcol(cell_options_->input_special_multialign, FL_INACTIVE);
- fl_set_input(cell_options_->input_mcolumn_width,"");
- fl_deactivate_object(cell_options_->input_mcolumn_width);
- fl_set_object_lcol(cell_options_->input_mcolumn_width, FL_INACTIVE);
- }
- if (tabular->GetRotateCell(cell))
- fl_set_button(cell_options_->radio_rotate_cell, 1);
- else
- fl_set_button(cell_options_->radio_rotate_cell, 0);
- if (tabular->TopLine(cell, true))
- fl_set_button(column_options_->radio_border_top, 1);
- else
- fl_set_button(column_options_->radio_border_top, 0);
- if (tabular->BottomLine(cell, true))
- fl_set_button(column_options_->radio_border_bottom, 1);
- else
- fl_set_button(column_options_->radio_border_bottom, 0);
- if (tabular->LeftLine(cell, true))
- fl_set_button(column_options_->radio_border_left, 1);
- else
- fl_set_button(column_options_->radio_border_left, 0);
- if (tabular->RightLine(cell, true))
- fl_set_button(column_options_->radio_border_right, 1);
- else
- fl_set_button(column_options_->radio_border_right, 0);
- special = tabular->GetAlignSpecial(cell,LyXTabular::SET_SPECIAL_COLUMN);
- fl_set_input(column_options_->input_special_alignment, special.c_str());
- if (lv_->buffer()->isReadonly())
- fl_deactivate_object(column_options_->input_special_alignment);
- else
- fl_activate_object(column_options_->input_special_alignment);
- pwidth = tabular->GetColumnPWidth(cell);
- fl_set_input(column_options_->input_column_width,pwidth.c_str());
- if (lv_->buffer()->isReadonly()) {
- fl_deactivate_object(column_options_->input_column_width);
- } else {
- fl_activate_object(column_options_->input_column_width);
- }
- if (!pwidth.empty()) {
- fl_activate_object(cell_options_->radio_useminipage);
- fl_set_object_lcol(cell_options_->radio_useminipage, FL_BLACK);
- if (tabular->GetUsebox(cell) == 2)
- fl_set_button(cell_options_->radio_useminipage, 1);
- else
- fl_set_button(cell_options_->radio_useminipage, 0);
- } else {
- fl_deactivate_object(cell_options_->radio_useminipage);
- fl_set_object_lcol(cell_options_->radio_useminipage, FL_INACTIVE);
- fl_set_button(cell_options_->radio_useminipage,0);
- }
- 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);
- if (!pwidth.empty() || (align == LYX_ALIGN_LEFT))
- fl_set_button(column_options_->radio_align_left, 1);
- else if (align == LYX_ALIGN_RIGHT)
- fl_set_button(column_options_->radio_align_right, 1);
- else
- fl_set_button(column_options_->radio_align_center, 1);
- 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.empty() || (align == LyXTabular::LYX_VALIGN_CENTER))
- fl_set_button(column_options_->radio_valign_center, 1);
- else if (align == LyXTabular::LYX_VALIGN_BOTTOM)
- fl_set_button(column_options_->radio_valign_bottom, 1);
- else
- fl_set_button(column_options_->radio_valign_top, 1);
- if (!pwidth.empty()) {
- fl_deactivate_object(column_options_->radio_align_left);
- fl_deactivate_object(column_options_->radio_align_right);
- fl_deactivate_object(column_options_->radio_align_center);
- fl_set_object_lcol(column_options_->radio_align_left, FL_INACTIVE);
- fl_set_object_lcol(column_options_->radio_align_right, FL_INACTIVE);
- fl_set_object_lcol(column_options_->radio_align_center, FL_INACTIVE);
- fl_activate_object(column_options_->radio_valign_top);
- fl_activate_object(column_options_->radio_valign_bottom);
- fl_activate_object(column_options_->radio_valign_center);
- fl_set_object_lcol(column_options_->radio_valign_top, FL_BLACK);
- fl_set_object_lcol(column_options_->radio_valign_bottom, FL_BLACK);
- fl_set_object_lcol(column_options_->radio_valign_center, FL_BLACK);
- } else {
- fl_activate_object(column_options_->radio_align_left);
- fl_activate_object(column_options_->radio_align_right);
- fl_activate_object(column_options_->radio_align_center);
- fl_set_object_lcol(column_options_->radio_align_left, FL_BLACK);
- fl_set_object_lcol(column_options_->radio_align_right, FL_BLACK);
- fl_set_object_lcol(column_options_->radio_align_center, FL_BLACK);
- fl_deactivate_object(column_options_->radio_valign_top);
- fl_deactivate_object(column_options_->radio_valign_bottom);
- fl_deactivate_object(column_options_->radio_valign_center);
- fl_set_object_lcol(column_options_->radio_valign_top, FL_INACTIVE);
- fl_set_object_lcol(column_options_->radio_valign_bottom, FL_INACTIVE);
- fl_set_object_lcol(column_options_->radio_valign_center, FL_INACTIVE);
- }
- fl_set_button(tabular_options_->radio_longtable,
- tabular->IsLongTabular());
- if (tabular->IsLongTabular()) {
- fl_activate_object(longtable_options_->radio_lt_firsthead);
- fl_activate_object(longtable_options_->radio_lt_head);
- fl_activate_object(longtable_options_->radio_lt_foot);
- fl_activate_object(longtable_options_->radio_lt_lastfoot);
- fl_activate_object(longtable_options_->radio_lt_newpage);
- fl_set_object_lcol(longtable_options_->radio_lt_firsthead, FL_BLACK);
- fl_set_object_lcol(longtable_options_->radio_lt_head, FL_BLACK);
- fl_set_object_lcol(longtable_options_->radio_lt_foot, FL_BLACK);
- fl_set_object_lcol(longtable_options_->radio_lt_lastfoot, FL_BLACK);
- fl_set_object_lcol(longtable_options_->radio_lt_newpage, FL_BLACK);
- 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_newpage,
- tabular->GetLTNewPage(cell));
- } else {
- fl_deactivate_object(longtable_options_->radio_lt_firsthead);
- fl_deactivate_object(longtable_options_->radio_lt_head);
- fl_deactivate_object(longtable_options_->radio_lt_foot);
- fl_deactivate_object(longtable_options_->radio_lt_lastfoot);
- fl_deactivate_object(longtable_options_->radio_lt_newpage);
- 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);
- fl_set_object_lcol(longtable_options_->radio_lt_firsthead,FL_INACTIVE);
- fl_set_object_lcol(longtable_options_->radio_lt_head, FL_INACTIVE);
- fl_set_object_lcol(longtable_options_->radio_lt_foot, FL_INACTIVE);
- fl_set_object_lcol(longtable_options_->radio_lt_lastfoot, FL_INACTIVE);
- fl_set_object_lcol(longtable_options_->radio_lt_newpage, FL_INACTIVE);
- }
- fl_set_button(tabular_options_->radio_rotate_tabular,
- tabular->GetRotateTabular());
- return true;
-}
-
-void FormTabular::SetTabularOptions(FL_OBJECT * ob, long)
-{
- if (!inset_)
- return;
-
- LyXTabular
- * tabular = inset_->tabular;
- int
- cell,
- s;
- LyXTabular::Feature
- num = LyXTabular::LAST_ACTION;
- string
- special,
- str;
-
- cell = inset_->GetActCell();
- if (actCell_ != cell) {
- local_update(false);
- fl_set_object_label(dialog_->text_warning,
- _("Warning: Wrong Cursor position, updated window"));
- fl_show_object(dialog_->text_warning);
- return;
- }
- // 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()) {
- local_update(false);
- return;
- }
- if (ob == column_options_->input_column_width) {
- string
- str;
- 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;
- }
- inset_->TabularFeatures(lv_->view(), LyXTabular::SET_PWIDTH,str);
- local_update(false); // update for alignment
- return;
- }
- if (ob == cell_options_->input_mcolumn_width) {
- string
- str;
- 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;
- }
- inset_->TabularFeatures(lv_->view(), LyXTabular::SET_MPWIDTH,str);
- local_update(false); // update for alignment
- return;
- }
- 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;
- }
- 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) {
- s=fl_get_button(tabular_options_->radio_longtable);
- if (s) {
- num = LyXTabular::SET_LONGTABULAR;
- fl_activate_object(longtable_options_->radio_lt_firsthead);
- fl_activate_object(longtable_options_->radio_lt_head);
- fl_activate_object(longtable_options_->radio_lt_foot);
- fl_activate_object(longtable_options_->radio_lt_lastfoot);
- fl_activate_object(longtable_options_->radio_lt_newpage);
- 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_deactivate_object(longtable_options_->radio_lt_firsthead);
- fl_deactivate_object(longtable_options_->radio_lt_head);
- fl_deactivate_object(longtable_options_->radio_lt_foot);
- fl_deactivate_object(longtable_options_->radio_lt_lastfoot);
- fl_deactivate_object(longtable_options_->radio_lt_newpage);
- 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);
- fl_set_object_lcol(longtable_options_->radio_lt_firsthead,
- FL_INACTIVE);
- fl_set_object_lcol(longtable_options_->radio_lt_head, FL_INACTIVE);
- fl_set_object_lcol(longtable_options_->radio_lt_foot, FL_INACTIVE);
- fl_set_object_lcol(longtable_options_->radio_lt_lastfoot,
- FL_INACTIVE);
- fl_set_object_lcol(longtable_options_->radio_lt_newpage,
- FL_INACTIVE);
- }
- } else if (ob == tabular_options_->radio_rotate_tabular) {
- s=fl_get_button(tabular_options_->radio_rotate_tabular);
- if (s)
- num = LyXTabular::SET_ROTATE_TABULAR;
+ 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_block, 0);
+ if (align == LYX_ALIGN_LEFT)
+ fl_set_button(column_options_->radio_align_left, 1);
+ else if (align == LYX_ALIGN_RIGHT)
+ fl_set_button(column_options_->radio_align_right, 1);
+ else if (align == LYX_ALIGN_CENTER)
+ fl_set_button(column_options_->radio_align_center, 1);
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;
+ fl_set_button(column_options_->radio_align_block, 1);
+ 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_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
- num = LyXTabular::UNSET_ROTATE_CELL;
- } else if (ob == cell_options_->radio_useminipage) {
- num = LyXTabular::SET_USEBOX;
- special = "2";
- } else if (ob == longtable_options_->radio_lt_firsthead) {
- num = LyXTabular::SET_LTFIRSTHEAD;
- } else if (ob == longtable_options_->radio_lt_head) {
- num = LyXTabular::SET_LTHEAD;
- } else if (ob == longtable_options_->radio_lt_foot) {
- num = LyXTabular::SET_LTFOOT;
- } else if (ob == longtable_options_->radio_lt_lastfoot) {
- num = LyXTabular::SET_LTLASTFOOT;
- } else if (ob == longtable_options_->radio_lt_newpage) {
- num = LyXTabular::SET_LTNEWPAGE;
- } else if (ob == column_options_->input_special_alignment) {
- special = fl_get_input(column_options_->input_special_alignment);
- num = LyXTabular::SET_SPECIAL_COLUMN;
- } else if (ob == cell_options_->input_special_multialign) {
- special = fl_get_input(cell_options_->input_special_multialign);
- num = LyXTabular::SET_SPECIAL_MULTI;
- } else if (ob == cell_options_->radio_border_top)
- num = LyXTabular::M_TOGGLE_LINE_TOP;
- else if (ob == cell_options_->radio_border_bottom)
- num = LyXTabular::M_TOGGLE_LINE_BOTTOM;
- else if (ob == cell_options_->radio_border_left)
- num = LyXTabular::M_TOGGLE_LINE_LEFT;
- else if (ob == cell_options_->radio_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_center)
- num = LyXTabular::M_VALIGN_CENTER;
- else
- return;
-
- inset_->TabularFeatures(lv_->view(), num, special);
- local_update(false);
+ fl_set_button(column_options_->radio_valign_top, 1);
+
+ setEnabled(column_options_->radio_align_left, true);
+ setEnabled(column_options_->radio_align_right, true);
+ setEnabled(column_options_->radio_align_center, true);
+ 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_middle, !pwidth.zero());
+
+ fl_set_button(tabular_options_->check_longtable,
+ tabular.isLongTabular());
+
+ bool const enable = tabular.isLongTabular();
+
+ setEnabled(longtable_options_->check_lt_firsthead, enable);
+ setEnabled(longtable_options_->check_1head_2border_above, enable);
+ setEnabled(longtable_options_->check_1head_2border_below, enable);
+ setEnabled(longtable_options_->check_1head_empty, enable);
+ setEnabled(longtable_options_->check_lt_head, enable);
+ setEnabled(longtable_options_->check_head_2border_above, enable);
+ setEnabled(longtable_options_->check_head_2border_below, enable);
+ setEnabled(longtable_options_->check_lt_foot, enable);
+ setEnabled(longtable_options_->check_foot_2border_above, enable);
+ setEnabled(longtable_options_->check_foot_2border_below, enable);
+ setEnabled(longtable_options_->check_lt_lastfoot, enable);
+ setEnabled(longtable_options_->check_lastfoot_2border_above, enable);
+ setEnabled(longtable_options_->check_lastfoot_2border_below, enable);
+ setEnabled(longtable_options_->check_lastfoot_empty, enable);
+ setEnabled(longtable_options_->check_lt_newpage, enable);
+
+ if (enable) {
+ LyXTabular::ltType ltt;
+ bool use_empty;
+ 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,
+ ltt.topDL);
+ fl_set_button(longtable_options_->check_head_2border_below,
+ ltt.bottomDL);
+ use_empty = true;
+ } else {
+ setEnabled(longtable_options_->check_head_2border_above, 0);
+ setEnabled(longtable_options_->check_head_2border_below, 0);
+ fl_set_button(longtable_options_->check_head_2border_above,0);
+ fl_set_button(longtable_options_->check_head_2border_below,0);
+ fl_set_button(longtable_options_->check_1head_empty,0);
+ setEnabled(longtable_options_->check_1head_empty, 0);
+ use_empty = false;
+ }
+ //
+ 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,
+ ltt.topDL);
+ fl_set_button(longtable_options_->check_1head_2border_below,
+ ltt.bottomDL);
+ } else {
+ setEnabled(longtable_options_->check_1head_2border_above, 0);
+ setEnabled(longtable_options_->check_1head_2border_below, 0);
+ fl_set_button(longtable_options_->check_1head_2border_above,0);
+ fl_set_button(longtable_options_->check_1head_2border_below,0);
+ if (use_empty) {
+ fl_set_button(longtable_options_->check_1head_empty,ltt.empty);
+ if (ltt.empty)
+ setEnabled(longtable_options_->check_lt_firsthead, 0);
+ }
+ }
+ //
+ 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,
+ ltt.topDL);
+ fl_set_button(longtable_options_->check_foot_2border_below,
+ ltt.bottomDL);
+ use_empty = true;
+ } else {
+ setEnabled(longtable_options_->check_foot_2border_above, 0);
+ setEnabled(longtable_options_->check_foot_2border_below, 0);
+ fl_set_button(longtable_options_->check_foot_2border_above,0);
+ fl_set_button(longtable_options_->check_foot_2border_below,0);
+ fl_set_button(longtable_options_->check_lastfoot_empty, 0);
+ setEnabled(longtable_options_->check_lastfoot_empty, 0);
+ use_empty = false;
+ }
+ //
+ 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,
+ ltt.topDL);
+ fl_set_button(longtable_options_->check_lastfoot_2border_below,
+ ltt.bottomDL);
+ } else {
+ setEnabled(longtable_options_->check_lastfoot_2border_above,0);
+ setEnabled(longtable_options_->check_lastfoot_2border_below,0);
+ fl_set_button(longtable_options_->check_lastfoot_2border_above, 0);
+ fl_set_button(longtable_options_->check_lastfoot_2border_below, 0);
+ if (use_empty) {
+ fl_set_button(longtable_options_->check_lastfoot_empty,
+ ltt.empty);
+ if (ltt.empty)
+ setEnabled(longtable_options_->check_lt_lastfoot, 0);
+ }
+ }
+ fl_set_button(longtable_options_->check_lt_newpage,
+ 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_1head_2border_below, 0);
+ fl_set_button(longtable_options_->check_1head_empty, 0);
+ fl_set_button(longtable_options_->check_lt_head, 0);
+ fl_set_button(longtable_options_->check_head_2border_above, 0);
+ fl_set_button(longtable_options_->check_head_2border_below, 0);
+ fl_set_button(longtable_options_->check_lt_foot, 0);
+ fl_set_button(longtable_options_->check_foot_2border_above, 0);
+ fl_set_button(longtable_options_->check_foot_2border_below, 0);
+ fl_set_button(longtable_options_->check_lt_lastfoot, 0);
+ fl_set_button(longtable_options_->check_lastfoot_2border_above, 0);
+ fl_set_button(longtable_options_->check_lastfoot_2border_below, 0);
+ fl_set_button(longtable_options_->check_lastfoot_empty, 0);
+ fl_set_button(longtable_options_->check_lt_newpage, 0);
+ }
+ fl_set_button(tabular_options_->check_rotate_tabular,
+ tabular.getRotateTabular());
}
-// +-----------------------------------------------------------------------+
-// | Functions/Dialogs for creating tabular insets |
-// +-----------------------------------------------------------------------+
-void FormTabular::show_create()
+ButtonPolicy::SMInput FormTabular::input(FL_OBJECT * ob, long)
{
- if (!dialog_) {
- build();
- }
- if (create_tabular_->form->visible) {
- fl_raise_form(create_tabular_->form);
- } else {
- fl_show_form(create_tabular_->form,
- FL_PLACE_MOUSE | FL_FREE_SIZE,
- FL_FULLBORDER, _("Insert Tabular"));
- }
-}
-
+ int s;
+ LyXTabular::Feature num = LyXTabular::LAST_ACTION;
+ string special;
+
+ LyXTabular const & tabular = controller().tabular();
+
+ int 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;
+ }
-void FormTabular::apply_create()
-{
- int
- xsize,ysize;
-
-// comm->setMinibuffer(_("Inserting tabular inset..."));
- ysize = int(fl_get_slider_value(create_tabular_->slider_columns) + 0.5);
- xsize = int(fl_get_slider_value(create_tabular_->slider_rows) + 0.5);
- InsetTabular * in = new InsetTabular(lv_->buffer(),xsize,ysize);
- if (!lv_->view()->open_new_inset(in)) {
- delete in;
- }
-// comm->setMinibuffer(_("Tabular mode"));
-}
+ 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;
+ }
-void FormTabular::hide_create()
-{
- if (create_tabular_->form &&
- create_tabular_->form->visible)
- fl_hide_form(create_tabular_->form);
-}
+ 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;
+ }
-void FormTabular::OKCB(FL_OBJECT * ob, long)
-{
- FormTabular * pre = (FormTabular*)ob->form->u_vdata;
- pre->apply_create();
- pre->hide_create();
-}
+ 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;
+ else
+ return ButtonPolicy::SMI_VALID;
+ controller().set(num, special);
+ update();
-void FormTabular::ApplyCB(FL_OBJECT * ob, long)
-{
- FormTabular * pre = (FormTabular*)ob->form->u_vdata;
- pre->apply_create();
+ return ButtonPolicy::SMI_VALID;
}
-void FormTabular::CancelCB(FL_OBJECT * ob, long)
+int FormTabular::checkLongtableOptions(FL_OBJECT * ob, string & special)
{
- FormTabular * pre = (FormTabular*)ob->form->u_vdata;
- pre->hide_create();
-}
-
+ bool flag = fl_get_button(ob);
+ if ((ob == longtable_options_->check_1head_2border_above) ||
+ (ob == longtable_options_->check_head_2border_above) ||
+ (ob == longtable_options_->check_foot_2border_above) ||
+ (ob == longtable_options_->check_lastfoot_2border_above)) {
+ special = "dl_above";
+ } else if ((ob == longtable_options_->check_1head_2border_below) ||
+ (ob == longtable_options_->check_head_2border_below) ||
+ (ob == longtable_options_->check_foot_2border_below) ||
+ (ob == longtable_options_->check_lastfoot_2border_below)) {
+ special = "dl_below";
+ } else if ((ob == longtable_options_->check_1head_empty) ||
+ (ob == longtable_options_->check_lastfoot_empty)) {
+ special = "empty";
+ } else {
+ special = "";
+ }
+ 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)) {
+ return (flag ? LyXTabular::SET_LTFIRSTHEAD :
+ LyXTabular::UNSET_LTFIRSTHEAD);
+ } else if ((ob == longtable_options_->check_lt_head) ||
+ (ob == longtable_options_->check_head_2border_above) ||
+ (ob == longtable_options_->check_head_2border_below)) {
+ return (flag ? LyXTabular::SET_LTHEAD : LyXTabular::UNSET_LTHEAD);
+ } else if ((ob == longtable_options_->check_lt_foot) ||
+ (ob == longtable_options_->check_foot_2border_above) ||
+ (ob == longtable_options_->check_foot_2border_below)) {
+ return (flag ? LyXTabular::SET_LTFOOT : LyXTabular::UNSET_LTFOOT);
+ } else if ((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)) {
+ return (flag ? LyXTabular::SET_LTLASTFOOT :
+ LyXTabular::UNSET_LTLASTFOOT);
+ }
+ return LyXTabular::LAST_ACTION;
+}