/**
* \file FormTabular.C
- * Copyright 2000-2001 The LyX Team.
- * See the file COPYING.
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * \author Jürgen Vigna, jug@sad.it
+ * \author Jürgen Vigna
+ *
+ * Full author contact details are available in file CREDITS
*/
#include <config.h>
#include "debug.h"
#include "FormTabular.h"
-#include "form_tabular.h"
-#include "LyXView.h"
-#include "Dialogs.h"
+#include "forms/form_tabular.h"
+#include "frontends/LyXView.h"
#include "buffer.h"
#include "xforms_helpers.h"
#include "lyxrc.h" // to set the default length values
#include "support/lstrings.h"
+#include <boost/bind.hpp>
+
#include <functional>
+#include FORMS_H_LOCATION
-using SigC::slot;
using std::vector;
using std::bind2nd;
using std::remove_if;
-FormTabular::FormTabular(LyXView * lv, Dialogs * d)
+FormTabular::FormTabular(LyXView & lv, Dialogs & d)
: FormInset(lv, d, _("Tabular Layout")),
inset_(0), actCell_(-1), closing_(false)
{
- // 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));
}
// If connected to another inset, disconnect from it.
if (inset_ != inset) {
ih_.disconnect();
- ih_ = inset->hideDialog.connect(slot(this, &FormTabular::hide));
+ ih_ = inset->hideDialog.connect(boost::bind(&FormTabular::hide, this));
inset_ = inset;
}
// If connected to another inset, disconnect from it.
if (inset_ != inset) {
ih_.disconnect();
- ih_ = inset->hideDialog.connect(slot(this, &FormTabular::hide));
+ ih_ = inset->hideDialog.connect(boost::bind(&FormTabular::hide, this));
inset_ = inset;
}
void FormTabular::build()
{
- dialog_.reset(build_tabular());
+ dialog_.reset(build_tabular(this));
// Allow the base class to control messages
setMessageWidget(dialog_->text_warning);
setPrehandler(dialog_->input_tabular_column);
setPrehandler(dialog_->input_tabular_row);
- tabular_options_.reset(build_tabular_options());
- column_options_.reset(build_column_options());
- cell_options_.reset(build_cell_options());
- longtable_options_.reset(build_longtable_options());
+ tabular_options_.reset(build_tabular_options(this));
+ column_options_.reset(build_tabular_column(this));
+ cell_options_.reset(build_tabular_cell(this));
+ longtable_options_.reset(build_tabular_longtable(this));
fl_set_input_return(column_options_->input_column_width,
- FL_RETURN_END);
+ FL_RETURN_END);
fl_set_input_return(column_options_->input_special_alignment,
- FL_RETURN_END);
+ FL_RETURN_END);
setPrehandler(column_options_->input_column_width);
setPrehandler(column_options_->input_special_alignment);
-
+
fl_set_input_return(cell_options_->input_mcolumn_width,
- FL_RETURN_END);
+ FL_RETURN_END);
fl_set_input_return(cell_options_->input_special_multialign,
- FL_RETURN_END);
+ FL_RETURN_END);
setPrehandler(cell_options_->input_mcolumn_width);
setPrehandler(cell_options_->input_special_multialign);
fl_addto_tabfolder(dialog_->tabfolder, _("Tabular"),
- tabular_options_->form);
+ tabular_options_->form);
fl_addto_tabfolder(dialog_->tabfolder, _("Column/Row"),
- column_options_->form);
+ column_options_->form);
fl_addto_tabfolder(dialog_->tabfolder, _("Cell"),
- cell_options_->form);
+ cell_options_->form);
fl_addto_tabfolder(dialog_->tabfolder, _("LongTable"),
- longtable_options_->form);
+ longtable_options_->form);
// Create the contents of the unit choices
// Don't include the "%" terms...
vector<string> units_vec = getLatexUnits();
-#if 0
- for (vector<string>::iterator it = units_vec.begin();
- it != units_vec.end(); ++it) {
- if (contains(*it, "%"))
- it = units_vec.erase(it, it + 1) - 1;
- }
-#else
vector<string>::iterator ret =
remove_if(units_vec.begin(), units_vec.end(),
- bind2nd(contains_functor(), "%"));
+ bind2nd(contains_functor(), "%"));
units_vec.erase(ret, units_vec.end());
-#endif
-
+
string units = getStringFromVector(units_vec, "|");
fl_addto_choice(column_options_->choice_value_column_width,
- units.c_str());
+ units.c_str());
fl_addto_choice(cell_options_->choice_value_mcolumn_width,
- units.c_str());
+ units.c_str());
}
{
if (closing_)
return;
-
+
if (!inset_ || !inset_->tabular.get())
return;
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
}
pwidth = tabular->GetMColumnPWidth(cell);
align = tabular->GetAlignment(cell);
- if (!pwidth.zero() || (align == LYX_ALIGN_LEFT))
+ if (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);
bool const metric = lyxrc.default_papersize > 3;
string const default_unit = metric ? "cm" : "in";
updateWidgetsFromLength(cell_options_->input_mcolumn_width,
- cell_options_->choice_value_mcolumn_width,
- pwidth, default_unit);
+ cell_options_->choice_value_mcolumn_width,
+ pwidth, default_unit);
- if (!lv_->buffer()->isReadonly()) {
+ if (!lv_.buffer()->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_center, !pwidth.zero());
-
- setEnabled(cell_options_->radio_align_left, pwidth.zero());
- setEnabled(cell_options_->radio_align_right, pwidth.zero());
- setEnabled(cell_options_->radio_align_center, 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);
special = tabular->GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
fl_set_input(column_options_->input_special_alignment, special.c_str());
- bool const isReadonly = lv_->buffer()->isReadonly();
+ bool const isReadonly = lv_.buffer()->isReadonly();
setEnabled(column_options_->input_special_alignment, !isReadonly);
pwidth = tabular->GetColumnPWidth(cell);
bool const metric = lyxrc.default_papersize > 3;
string const default_unit = metric ? "cm" : "in";
updateWidgetsFromLength(column_options_->input_column_width,
- column_options_->choice_value_column_width,
- pwidth, default_unit);
+ column_options_->choice_value_column_width,
+ pwidth, default_unit);
setEnabled(column_options_->input_column_width, !isReadonly);
setEnabled(column_options_->choice_value_column_width, !isReadonly);
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.zero() || (align == LYX_ALIGN_LEFT))
+ 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
fl_set_button(column_options_->radio_valign_top, 1);
- setEnabled(column_options_->radio_align_left, pwidth.zero());
- setEnabled(column_options_->radio_align_right, pwidth.zero());
- setEnabled(column_options_->radio_align_center, pwidth.zero());
-
+ 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_valign_top, !pwidth.zero());
setEnabled(column_options_->radio_valign_bottom, !pwidth.zero());
setEnabled(column_options_->radio_valign_center, !pwidth.zero());
fl_set_button(tabular_options_->check_longtable,
- tabular->IsLongTabular());
+ 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);
fl_set_button(longtable_options_->check_lt_head, row_set);
if (ltt.set) {
fl_set_button(longtable_options_->check_head_2border_above,
- ltt.topDL);
+ ltt.topDL);
fl_set_button(longtable_options_->check_head_2border_above,
- ltt.topDL);
+ ltt.topDL);
use_empty = true;
} else {
setEnabled(longtable_options_->check_head_2border_above, 0);
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);
+ ltt.topDL);
fl_set_button(longtable_options_->check_1head_2border_above,
- ltt.topDL);
+ ltt.topDL);
} else {
setEnabled(longtable_options_->check_1head_2border_above, 0);
setEnabled(longtable_options_->check_1head_2border_below, 0);
fl_set_button(longtable_options_->check_lt_foot, row_set);
if (ltt.set) {
fl_set_button(longtable_options_->check_foot_2border_above,
- ltt.topDL);
+ ltt.topDL);
fl_set_button(longtable_options_->check_foot_2border_above,
- ltt.topDL);
+ ltt.topDL);
use_empty = true;
} else {
setEnabled(longtable_options_->check_foot_2border_above, 0);
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);
+ ltt.topDL);
fl_set_button(longtable_options_->check_lastfoot_2border_above,
- ltt.topDL);
+ ltt.topDL);
} 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);
if (use_empty) {
fl_set_button(longtable_options_->check_lastfoot_empty,
- ltt.empty);
+ ltt.empty);
if (ltt.empty)
setEnabled(longtable_options_->check_lt_lastfoot, 0);
}
}
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());
}
if (str1 != str2)
input(column_options_->input_column_width, 0);
str1 = getLengthFromWidgets(cell_options_->input_mcolumn_width,
- cell_options_->choice_value_mcolumn_width);
+ cell_options_->choice_value_mcolumn_width);
llen = tabular->GetMColumnPWidth(cell);
if (llen.zero())
str2 = "";
ok();
return true;
}
-
+
if (actCell_ != cell) {
update();
postWarning(_("Wrong Cursor position, updated window"));
}
// 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()) {
+ if (lv_.buffer()->isReadonly()) {
update();
return false;
}
string const str =
getLengthFromWidgets(column_options_->input_column_width,
column_options_->choice_value_column_width);
- inset_->tabularFeatures(lv_->view(), LyXTabular::SET_PWIDTH, str);
+ inset_->tabularFeatures(lv_.view().get(), LyXTabular::SET_PWIDTH, str);
//check if the input is valid
string const input =
update(); // update for alignment
return true;
}
-
+
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);
- inset_->tabularFeatures(lv_->view(), LyXTabular::SET_MPWIDTH, str);
+ inset_->tabularFeatures(lv_.view().get(), LyXTabular::SET_MPWIDTH, str);
//check if the input is valid
string const input =
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)) {
+ (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;
num = LyXTabular::M_VALIGN_CENTER;
else
return false;
-
- inset_->tabularFeatures(lv_->view(), num, special);
+
+ inset_->tabularFeatures(lv_.view().get(), num, special);
update();
return true;