2000-10-24 13:13:59 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 1995 Matthias Ettrich
|
|
|
|
* Copyright 1995-2000 The LyX Team.
|
|
|
|
*
|
|
|
|
*======================================================*/
|
2000-07-11 15:08:54 +00:00
|
|
|
/* FormTabular.C
|
|
|
|
* FormTabular Interface Class Implementation
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2001-03-15 13:37:04 +00:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
2000-07-11 15:08:54 +00:00
|
|
|
#include "FormTabular.h"
|
2000-07-14 14:57:20 +00:00
|
|
|
#include "form_tabular.h"
|
2000-07-11 15:08:54 +00:00
|
|
|
#include "LyXView.h"
|
|
|
|
#include "Dialogs.h"
|
|
|
|
#include "insets/insettabular.h"
|
|
|
|
#include "buffer.h"
|
2001-03-05 19:02:40 +00:00
|
|
|
#include "xforms_helpers.h"
|
2000-07-11 15:08:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
FormTabular::FormTabular(LyXView * lv, Dialogs * d)
|
2001-03-15 13:37:04 +00:00
|
|
|
: FormInset(lv, d, _("Tabular Layout")),
|
2000-10-24 13:13:59 +00:00
|
|
|
inset_(0), actCell_(-1)
|
2000-07-11 15:08:54 +00:00
|
|
|
{
|
2000-10-24 13:13:59 +00:00
|
|
|
// 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));
|
2000-07-11 15:08:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-10 17:29:47 +00:00
|
|
|
void FormTabular::redraw()
|
|
|
|
{
|
2000-11-14 02:01:57 +00:00
|
|
|
if(form() && form()->visible)
|
|
|
|
fl_redraw_form(form());
|
2000-11-10 17:29:47 +00:00
|
|
|
else
|
|
|
|
return;
|
|
|
|
|
|
|
|
FL_FORM * outer_form = fl_get_active_folder(dialog_->tabFolder);
|
|
|
|
if (outer_form && outer_form->visible)
|
2000-11-14 02:01:57 +00:00
|
|
|
fl_redraw_form(outer_form);
|
2000-11-10 17:29:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-24 13:13:59 +00:00
|
|
|
FL_FORM * FormTabular::form() const
|
2000-07-11 15:08:54 +00:00
|
|
|
{
|
2001-03-15 13:37:04 +00:00
|
|
|
if (dialog_.get())
|
|
|
|
return dialog_->form;
|
2000-10-24 13:13:59 +00:00
|
|
|
return 0;
|
2000-07-11 15:08:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-24 13:13:59 +00:00
|
|
|
void FormTabular::disconnect()
|
2000-07-11 15:08:54 +00:00
|
|
|
{
|
|
|
|
inset_ = 0;
|
2000-10-24 13:13:59 +00:00
|
|
|
FormInset::disconnect();
|
2000-07-11 15:08:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-14 02:01:57 +00:00
|
|
|
void FormTabular::showInset(InsetTabular * inset)
|
2000-07-11 15:08:54 +00:00
|
|
|
{
|
2000-10-24 13:13:59 +00:00
|
|
|
if (inset == 0) return;
|
2000-07-11 15:08:54 +00:00
|
|
|
|
2000-10-24 13:13:59 +00:00
|
|
|
// If connected to another inset, disconnect from it.
|
|
|
|
if (inset_ != inset) {
|
|
|
|
ih_.disconnect();
|
|
|
|
ih_ = inset->hideDialog.connect(slot(this, &FormTabular::hide));
|
|
|
|
inset_ = inset;
|
|
|
|
}
|
2000-07-11 15:08:54 +00:00
|
|
|
|
2000-10-24 13:13:59 +00:00
|
|
|
show();
|
2000-07-11 15:08:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-14 02:01:57 +00:00
|
|
|
void FormTabular::updateInset(InsetTabular * inset)
|
2000-07-11 15:08:54 +00:00
|
|
|
{
|
2000-10-24 13:13:59 +00:00
|
|
|
if (inset == 0 || inset_ == 0) return;
|
2000-07-11 15:08:54 +00:00
|
|
|
|
2000-10-24 13:13:59 +00:00
|
|
|
// If connected to another inset, disconnect from it.
|
|
|
|
if (inset_ != inset) {
|
|
|
|
ih_.disconnect();
|
|
|
|
ih_ = inset->hideDialog.connect(slot(this, &FormTabular::hide));
|
|
|
|
inset_ = inset;
|
|
|
|
}
|
2000-07-11 15:08:54 +00:00
|
|
|
|
2000-10-24 13:13:59 +00:00
|
|
|
update();
|
2000-07-11 15:08:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-24 13:13:59 +00:00
|
|
|
void FormTabular::build()
|
2000-07-11 15:08:54 +00:00
|
|
|
{
|
2001-03-15 13:37:04 +00:00
|
|
|
dialog_.reset(build_tabular());
|
|
|
|
tabular_options_.reset(build_tabular_options());
|
|
|
|
column_options_.reset(build_column_options());
|
|
|
|
cell_options_.reset(build_cell_options());
|
|
|
|
longtable_options_.reset(build_longtable_options());
|
2000-10-24 13:13:59 +00:00
|
|
|
|
|
|
|
// Workaround dumb xforms sizing bug
|
|
|
|
minw_ = form()->w;
|
|
|
|
minh_ = form()->h;
|
|
|
|
|
|
|
|
fl_set_input_return(column_options_->input_column_width,
|
|
|
|
FL_RETURN_END);
|
|
|
|
fl_set_input_return(column_options_->input_special_alignment,
|
2001-02-19 16:01:31 +00:00
|
|
|
FL_RETURN_END);
|
2000-10-24 13:13:59 +00:00
|
|
|
fl_set_input_return(cell_options_->input_mcolumn_width,
|
2001-02-19 16:01:31 +00:00
|
|
|
FL_RETURN_END);
|
2000-10-24 13:13:59 +00:00
|
|
|
fl_set_input_return(cell_options_->input_special_multialign,
|
2001-02-19 16:01:31 +00:00
|
|
|
FL_RETURN_END);
|
2000-10-24 13:13:59 +00:00
|
|
|
|
|
|
|
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);
|
2000-07-11 15:08:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-24 13:13:59 +00:00
|
|
|
void FormTabular::update()
|
2000-07-11 15:08:54 +00:00
|
|
|
{
|
2000-10-24 13:13:59 +00:00
|
|
|
if (!inset_ || !inset_->tabular)
|
|
|
|
return;
|
|
|
|
|
2000-11-14 02:01:57 +00:00
|
|
|
LyXTabular * tabular = inset_->tabular;
|
2000-10-24 13:13:59 +00:00
|
|
|
int
|
|
|
|
align,
|
2000-11-14 02:01:57 +00:00
|
|
|
cell;
|
2000-10-24 13:13:59 +00:00
|
|
|
char
|
|
|
|
buf[12];
|
|
|
|
string
|
|
|
|
pwidth, special;
|
|
|
|
|
|
|
|
actCell_ = cell = inset_->GetActCell();
|
2000-11-14 02:01:57 +00:00
|
|
|
int column = tabular->column_of_cell(cell)+1;
|
2000-10-24 13:13:59 +00:00
|
|
|
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);
|
2000-11-14 02:01:57 +00:00
|
|
|
int row = tabular->row_of_cell(cell)+1;
|
2000-10-24 13:13:59 +00:00
|
|
|
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);
|
2001-03-05 19:02:40 +00:00
|
|
|
setEnabled(cell_options_->radio_border_top, true);
|
2000-10-24 13:13:59 +00:00
|
|
|
fl_set_button(cell_options_->radio_border_bottom,
|
|
|
|
tabular->BottomLine(cell)?1:0);
|
2001-03-05 19:02:40 +00:00
|
|
|
setEnabled(cell_options_->radio_border_bottom, true);
|
2000-10-24 13:13:59 +00:00
|
|
|
fl_set_button(cell_options_->radio_border_left,
|
|
|
|
tabular->LeftLine(cell)?1:0);
|
2001-03-05 19:02:40 +00:00
|
|
|
setEnabled(cell_options_->radio_border_left, true);
|
2000-10-24 13:13:59 +00:00
|
|
|
fl_set_button(cell_options_->radio_border_right,
|
|
|
|
tabular->RightLine(cell)?1:0);
|
2001-03-05 19:02:40 +00:00
|
|
|
setEnabled(cell_options_->radio_border_right, true);
|
2000-10-24 13:13:59 +00:00
|
|
|
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);
|
|
|
|
else
|
|
|
|
fl_set_button(cell_options_->radio_align_center, 1);
|
2001-03-05 19:02:40 +00:00
|
|
|
setEnabled(cell_options_->radio_align_left, true);
|
|
|
|
setEnabled(cell_options_->radio_align_right, true);
|
|
|
|
setEnabled(cell_options_->radio_align_center, true);
|
2000-10-24 13:13:59 +00:00
|
|
|
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);
|
|
|
|
else
|
|
|
|
fl_set_button(cell_options_->radio_valign_top, 1);
|
2001-03-05 19:02:40 +00:00
|
|
|
setEnabled(cell_options_->radio_valign_top, true);
|
|
|
|
setEnabled(cell_options_->radio_valign_bottom, true);
|
|
|
|
setEnabled(cell_options_->radio_valign_center, true);
|
2000-10-24 13:13:59 +00:00
|
|
|
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()) {
|
2001-03-05 19:02:40 +00:00
|
|
|
setEnabled(cell_options_->input_special_multialign, true);
|
|
|
|
setEnabled(cell_options_->input_mcolumn_width, true);
|
2000-10-24 13:13:59 +00:00
|
|
|
}
|
2001-03-05 19:02:40 +00:00
|
|
|
|
|
|
|
setEnabled(cell_options_->radio_valign_top, !pwidth.empty());
|
|
|
|
setEnabled(cell_options_->radio_valign_bottom, !pwidth.empty());
|
|
|
|
setEnabled(cell_options_->radio_valign_center, !pwidth.empty());
|
|
|
|
|
|
|
|
setEnabled(cell_options_->radio_align_left, pwidth.empty());
|
|
|
|
setEnabled(cell_options_->radio_align_right, pwidth.empty());
|
|
|
|
setEnabled(cell_options_->radio_align_center, pwidth.empty());
|
2000-10-24 13:13:59 +00:00
|
|
|
} else {
|
|
|
|
fl_set_button(cell_options_->radio_multicolumn, 0);
|
2001-03-05 19:02:40 +00:00
|
|
|
|
2000-10-24 13:13:59 +00:00
|
|
|
fl_set_button(cell_options_->radio_border_top, 0);
|
2001-03-05 19:02:40 +00:00
|
|
|
setEnabled(cell_options_->radio_border_top, false);
|
|
|
|
|
2000-10-24 13:13:59 +00:00
|
|
|
fl_set_button(cell_options_->radio_border_bottom, 0);
|
2001-03-05 19:02:40 +00:00
|
|
|
setEnabled(cell_options_->radio_border_bottom, false);
|
|
|
|
|
2000-10-24 13:13:59 +00:00
|
|
|
fl_set_button(cell_options_->radio_border_left, 0);
|
2001-03-05 19:02:40 +00:00
|
|
|
setEnabled(cell_options_->radio_border_left, false);
|
|
|
|
|
2000-10-24 13:13:59 +00:00
|
|
|
fl_set_button(cell_options_->radio_border_right, 0);
|
2001-03-05 19:02:40 +00:00
|
|
|
setEnabled(cell_options_->radio_border_right, false);
|
|
|
|
|
2000-10-24 13:13:59 +00:00
|
|
|
fl_set_button(cell_options_->radio_align_left, 0);
|
2001-03-05 19:02:40 +00:00
|
|
|
setEnabled(cell_options_->radio_align_left, false);
|
|
|
|
|
2000-10-24 13:13:59 +00:00
|
|
|
fl_set_button(cell_options_->radio_align_right, 0);
|
2001-03-05 19:02:40 +00:00
|
|
|
setEnabled(cell_options_->radio_align_right, false);
|
|
|
|
|
2000-10-24 13:13:59 +00:00
|
|
|
fl_set_button(cell_options_->radio_align_center, 0);
|
2001-03-05 19:02:40 +00:00
|
|
|
setEnabled(cell_options_->radio_align_center, false);
|
|
|
|
|
2000-10-24 13:13:59 +00:00
|
|
|
fl_set_button(cell_options_->radio_valign_top, 0);
|
2001-03-05 19:02:40 +00:00
|
|
|
setEnabled(cell_options_->radio_valign_top, false);
|
|
|
|
|
2000-10-24 13:13:59 +00:00
|
|
|
fl_set_button(cell_options_->radio_valign_bottom, 0);
|
2001-03-05 19:02:40 +00:00
|
|
|
setEnabled(cell_options_->radio_valign_bottom, false);
|
|
|
|
|
2000-10-24 13:13:59 +00:00
|
|
|
fl_set_button(cell_options_->radio_valign_center, 0);
|
2001-03-05 19:02:40 +00:00
|
|
|
setEnabled(cell_options_->radio_valign_center, false);
|
|
|
|
|
2000-10-24 13:13:59 +00:00
|
|
|
fl_set_input(cell_options_->input_special_multialign, "");
|
2001-03-05 19:02:40 +00:00
|
|
|
setEnabled(cell_options_->input_special_multialign, false);
|
|
|
|
|
|
|
|
fl_set_input(cell_options_->input_mcolumn_width, "");
|
|
|
|
setEnabled(cell_options_->input_mcolumn_width, false);
|
2000-10-24 13:13:59 +00:00
|
|
|
}
|
|
|
|
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());
|
2001-03-05 19:02:40 +00:00
|
|
|
|
|
|
|
bool const isReadonly = lv_->buffer()->isReadonly();
|
|
|
|
setEnabled(column_options_->input_special_alignment, !isReadonly);
|
|
|
|
|
2000-10-24 13:13:59 +00:00
|
|
|
pwidth = tabular->GetColumnPWidth(cell);
|
|
|
|
fl_set_input(column_options_->input_column_width,pwidth.c_str());
|
2001-03-05 19:02:40 +00:00
|
|
|
setEnabled(column_options_->input_column_width, !isReadonly);
|
|
|
|
|
|
|
|
setEnabled(cell_options_->radio_useminipage, !pwidth.empty());
|
2000-10-24 13:13:59 +00:00
|
|
|
if (!pwidth.empty()) {
|
|
|
|
if (tabular->GetUsebox(cell) == 2)
|
|
|
|
fl_set_button(cell_options_->radio_useminipage, 1);
|
|
|
|
else
|
|
|
|
fl_set_button(cell_options_->radio_useminipage, 0);
|
|
|
|
} else {
|
|
|
|
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);
|
2000-07-17 14:31:07 +00:00
|
|
|
if (!pwidth.empty() || (align == LYX_ALIGN_LEFT))
|
2000-10-24 13:13:59 +00:00
|
|
|
fl_set_button(column_options_->radio_align_left, 1);
|
2000-07-17 14:31:07 +00:00
|
|
|
else if (align == LYX_ALIGN_RIGHT)
|
2000-10-24 13:13:59 +00:00
|
|
|
fl_set_button(column_options_->radio_align_right, 1);
|
2000-07-17 14:31:07 +00:00
|
|
|
else
|
2000-10-24 13:13:59 +00:00
|
|
|
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);
|
2000-07-17 14:31:07 +00:00
|
|
|
if (pwidth.empty() || (align == LyXTabular::LYX_VALIGN_CENTER))
|
2000-10-24 13:13:59 +00:00
|
|
|
fl_set_button(column_options_->radio_valign_center, 1);
|
2000-07-17 14:31:07 +00:00
|
|
|
else if (align == LyXTabular::LYX_VALIGN_BOTTOM)
|
2000-10-24 13:13:59 +00:00
|
|
|
fl_set_button(column_options_->radio_valign_bottom, 1);
|
2000-07-17 14:31:07 +00:00
|
|
|
else
|
2000-10-24 13:13:59 +00:00
|
|
|
fl_set_button(column_options_->radio_valign_top, 1);
|
2001-03-05 19:02:40 +00:00
|
|
|
|
|
|
|
setEnabled(column_options_->radio_align_left, pwidth.empty());
|
|
|
|
setEnabled(column_options_->radio_align_right, pwidth.empty());
|
|
|
|
setEnabled(column_options_->radio_align_center, pwidth.empty());
|
|
|
|
|
|
|
|
setEnabled(column_options_->radio_valign_top, !pwidth.empty());
|
|
|
|
setEnabled(column_options_->radio_valign_bottom, !pwidth.empty());
|
|
|
|
setEnabled(column_options_->radio_valign_center, !pwidth.empty());
|
|
|
|
|
2000-10-24 13:13:59 +00:00
|
|
|
fl_set_button(tabular_options_->radio_longtable,
|
|
|
|
tabular->IsLongTabular());
|
2001-03-05 19:02:40 +00:00
|
|
|
|
|
|
|
bool const enable = tabular->IsLongTabular();
|
|
|
|
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) {
|
2000-10-24 13:13:59 +00:00
|
|
|
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_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_button(tabular_options_->radio_rotate_tabular,
|
|
|
|
tabular->GetRotateTabular());
|
2000-07-11 15:08:54 +00:00
|
|
|
}
|
|
|
|
|
2000-10-24 13:13:59 +00:00
|
|
|
bool FormTabular::input(FL_OBJECT * ob, long)
|
2000-07-13 15:03:34 +00:00
|
|
|
{
|
|
|
|
if (!inset_)
|
2000-10-24 13:13:59 +00:00
|
|
|
return false;
|
2000-07-13 15:03:34 +00:00
|
|
|
|
2000-11-14 02:01:57 +00:00
|
|
|
LyXTabular * tabular = inset_->tabular;
|
|
|
|
int s;
|
|
|
|
LyXTabular::Feature num = LyXTabular::LAST_ACTION;
|
|
|
|
string special;;
|
|
|
|
|
|
|
|
int cell = inset_->GetActCell();
|
2000-07-13 15:03:34 +00:00
|
|
|
if (actCell_ != cell) {
|
2000-10-24 13:13:59 +00:00
|
|
|
update();
|
2000-07-13 15:03:34 +00:00
|
|
|
fl_set_object_label(dialog_->text_warning,
|
|
|
|
_("Warning: Wrong Cursor position, updated window"));
|
|
|
|
fl_show_object(dialog_->text_warning);
|
2000-10-24 13:13:59 +00:00
|
|
|
return false;
|
2000-07-13 15:03:34 +00:00
|
|
|
}
|
|
|
|
// 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()) {
|
2000-10-24 13:13:59 +00:00
|
|
|
update();
|
|
|
|
return false;
|
2000-07-13 15:03:34 +00:00
|
|
|
}
|
|
|
|
if (ob == column_options_->input_column_width) {
|
2000-11-14 02:01:57 +00:00
|
|
|
string str = fl_get_input(ob);
|
2000-07-13 15:03:34 +00:00
|
|
|
if (!str.empty() && !isValidLength(str)) {
|
|
|
|
fl_set_object_label(dialog_->text_warning,
|
|
|
|
_("Warning: Invalid Length (valid example: 10mm)"));
|
|
|
|
fl_show_object(dialog_->text_warning);
|
2000-10-24 13:13:59 +00:00
|
|
|
return false;
|
2000-07-13 15:03:34 +00:00
|
|
|
}
|
|
|
|
inset_->TabularFeatures(lv_->view(), LyXTabular::SET_PWIDTH,str);
|
2000-10-24 13:13:59 +00:00
|
|
|
update(); // update for alignment
|
|
|
|
return true;
|
2000-07-13 15:03:34 +00:00
|
|
|
}
|
2000-07-17 14:31:07 +00:00
|
|
|
if (ob == cell_options_->input_mcolumn_width) {
|
2000-11-14 02:01:57 +00:00
|
|
|
string str = fl_get_input(ob);
|
2000-07-17 14:31:07 +00:00
|
|
|
if (!str.empty() && !isValidLength(str)) {
|
|
|
|
fl_set_object_label(dialog_->text_warning,
|
|
|
|
_("Warning: Invalid Length (valid example: 10mm)"));
|
|
|
|
fl_show_object(dialog_->text_warning);
|
2000-10-24 13:13:59 +00:00
|
|
|
return false;
|
2000-07-17 14:31:07 +00:00
|
|
|
}
|
|
|
|
inset_->TabularFeatures(lv_->view(), LyXTabular::SET_MPWIDTH,str);
|
2000-10-24 13:13:59 +00:00
|
|
|
update(); // update for alignment
|
|
|
|
return true;
|
2000-07-17 14:31:07 +00:00
|
|
|
}
|
2000-11-14 02:01:57 +00:00
|
|
|
string str = fl_get_input(column_options_->input_column_width);
|
2000-07-13 15:03:34 +00:00
|
|
|
if (!str.empty() && !isValidLength(str)) {
|
|
|
|
fl_set_object_label(
|
|
|
|
dialog_->text_warning,
|
|
|
|
_("Warning: Invalid Length (valid example: 10mm)"));
|
|
|
|
fl_show_object(dialog_->text_warning);
|
2000-10-24 13:13:59 +00:00
|
|
|
return false;
|
2000-07-13 15:03:34 +00:00
|
|
|
}
|
|
|
|
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;
|
2000-07-17 14:31:07 +00:00
|
|
|
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;
|
2000-07-13 15:03:34 +00:00
|
|
|
else if (ob == cell_options_->radio_multicolumn)
|
|
|
|
num = LyXTabular::MULTICOLUMN;
|
|
|
|
else if (ob == tabular_options_->radio_longtable) {
|
2001-03-05 19:02:40 +00:00
|
|
|
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);
|
|
|
|
}
|
2000-07-13 15:03:34 +00:00
|
|
|
} else if (ob == tabular_options_->radio_rotate_tabular) {
|
2000-11-14 02:01:57 +00:00
|
|
|
s = fl_get_button(tabular_options_->radio_rotate_tabular);
|
2000-07-13 15:03:34 +00:00
|
|
|
if (s)
|
|
|
|
num = LyXTabular::SET_ROTATE_TABULAR;
|
|
|
|
else
|
|
|
|
num = LyXTabular::UNSET_ROTATE_TABULAR;
|
|
|
|
} else if (ob == cell_options_->radio_rotate_cell) {
|
2000-11-14 02:01:57 +00:00
|
|
|
s = fl_get_button(cell_options_->radio_rotate_cell);
|
2000-07-13 15:03:34 +00:00
|
|
|
if (s)
|
|
|
|
num = LyXTabular::SET_ROTATE_CELL;
|
|
|
|
else
|
|
|
|
num = LyXTabular::UNSET_ROTATE_CELL;
|
2000-07-31 12:30:10 +00:00
|
|
|
} else if (ob == cell_options_->radio_useminipage) {
|
|
|
|
num = LyXTabular::SET_USEBOX;
|
|
|
|
special = "2";
|
2000-07-13 15:03:34 +00:00
|
|
|
} 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;
|
2000-07-17 14:31:07 +00:00
|
|
|
} 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
|
2000-10-24 13:13:59 +00:00
|
|
|
return false;
|
2000-07-13 15:03:34 +00:00
|
|
|
|
|
|
|
inset_->TabularFeatures(lv_->view(), num, special);
|
2000-10-24 13:13:59 +00:00
|
|
|
update();
|
2000-07-11 15:08:54 +00:00
|
|
|
|
2000-10-24 13:13:59 +00:00
|
|
|
return true;
|
2000-07-11 15:08:54 +00:00
|
|
|
}
|