Alains patch for setting tabular column global settings.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5217 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Vigna 2002-09-06 13:41:19 +00:00
parent f75f152e5b
commit 1c090286fe
7 changed files with 55 additions and 13 deletions

View File

@ -1,3 +1,13 @@
2002-09-06 Alain Castera <castera@in2p3.fr>
* tabular.C: uses \tabularnewline; uses >{...} construct from array
package to set the horizontal alignment on fixed width columns.
* lyx_sty.C:
* lyx_sty.h: added tabularnewline macro def.
* LaTeXFeatures.C: added NeedTabularnewline macro feature
2002-09-06 John Levon <levon@movementarian.org> 2002-09-06 John Levon <levon@movementarian.org>
* LyXAction.C: tooltips for sub/superscript * LyXAction.C: tooltips for sub/superscript

View File

@ -339,6 +339,10 @@ string const LaTeXFeatures::getMacros() const
if (isRequired("NeedLyXFootnoteCode")) if (isRequired("NeedLyXFootnoteCode"))
macros << floatingfootnote_def; macros << floatingfootnote_def;
// some problems with tex->html converters
if (isRequired("NeedTabularnewline"))
macros << tabularnewline_def;
// floats // floats
getFloatDefinitions(macros); getFloatDefinitions(macros);

View File

@ -1,3 +1,8 @@
2002-09-06 Alain Castera <castera@in2p3.fr>
* FormTabular.C: leave the horizontal alignment buttons alive
on fixed width columns
2002-09-05 Angus Leeming <leeming@lyx.org> 2002-09-05 Angus Leeming <leeming@lyx.org>
* all files: modify the headers as discussed on the list. * all files: modify the headers as discussed on the list.

View File

@ -222,7 +222,7 @@ void FormTabular::update()
} }
pwidth = tabular->GetMColumnPWidth(cell); pwidth = tabular->GetMColumnPWidth(cell);
align = tabular->GetAlignment(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); fl_set_button(cell_options_->radio_align_left, 1);
else if (align == LYX_ALIGN_RIGHT) else if (align == LYX_ALIGN_RIGHT)
fl_set_button(cell_options_->radio_align_right, 1); fl_set_button(cell_options_->radio_align_right, 1);
@ -258,9 +258,9 @@ void FormTabular::update()
setEnabled(cell_options_->radio_valign_bottom, !pwidth.zero()); setEnabled(cell_options_->radio_valign_bottom, !pwidth.zero());
setEnabled(cell_options_->radio_valign_center, !pwidth.zero()); setEnabled(cell_options_->radio_valign_center, !pwidth.zero());
setEnabled(cell_options_->radio_align_left, pwidth.zero()); setEnabled(cell_options_->radio_align_left, true);
setEnabled(cell_options_->radio_align_right, pwidth.zero()); setEnabled(cell_options_->radio_align_right, true);
setEnabled(cell_options_->radio_align_center, pwidth.zero()); setEnabled(cell_options_->radio_align_center, true);
} else { } else {
fl_set_button(cell_options_->check_multicolumn, 0); fl_set_button(cell_options_->check_multicolumn, 0);
@ -349,7 +349,7 @@ void FormTabular::update()
fl_set_button(column_options_->radio_align_left, 0); 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_right, 0);
fl_set_button(column_options_->radio_align_center, 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); fl_set_button(column_options_->radio_align_left, 1);
else if (align == LYX_ALIGN_RIGHT) else if (align == LYX_ALIGN_RIGHT)
fl_set_button(column_options_->radio_align_right, 1); fl_set_button(column_options_->radio_align_right, 1);
@ -366,10 +366,9 @@ void FormTabular::update()
else else
fl_set_button(column_options_->radio_valign_top, 1); fl_set_button(column_options_->radio_valign_top, 1);
setEnabled(column_options_->radio_align_left, pwidth.zero()); setEnabled(column_options_->radio_align_left, true);
setEnabled(column_options_->radio_align_right, pwidth.zero()); setEnabled(column_options_->radio_align_right, true);
setEnabled(column_options_->radio_align_center, pwidth.zero()); setEnabled(column_options_->radio_align_center, true);
setEnabled(column_options_->radio_valign_top, !pwidth.zero()); setEnabled(column_options_->radio_valign_top, !pwidth.zero());
setEnabled(column_options_->radio_valign_bottom, !pwidth.zero()); setEnabled(column_options_->radio_valign_bottom, !pwidth.zero());
setEnabled(column_options_->radio_valign_center, !pwidth.zero()); setEnabled(column_options_->radio_valign_center, !pwidth.zero());

View File

@ -118,3 +118,7 @@ string const binom_def =
string const mathcircumflex_def = string const mathcircumflex_def =
"%% For printing a cirumflex inside a formula\n" "%% For printing a cirumflex inside a formula\n"
"\\newcommand{\\mathcircumflex}[0]{\\mbox{\\^{}}}\n"; "\\newcommand{\\mathcircumflex}[0]{\\mbox{\\^{}}}\n";
string const tabularnewline_def =
"%% Because html converters don't know tabularnewline\n"
"\\providecommand{\\tabularnewline}{\\\\}\n";

View File

@ -49,5 +49,7 @@ extern string const boldsymbol_def;
extern string const binom_def; extern string const binom_def;
/// ///
extern string const mathcircumflex_def; extern string const mathcircumflex_def;
///
extern string const tabularnewline_def;
#endif // LYX_STY_H #endif // LYX_STY_H

View File

@ -751,8 +751,9 @@ bool LyXTabular::SetColumnPWidth(int cell, LyXLength const & width)
int const j = column_of_cell(cell); int const j = column_of_cell(cell);
column_info[j].p_width = width; column_info[j].p_width = width;
if (flag) // do this only if there is a width // This should not ne necessary anymore
SetAlignment(cell, LYX_ALIGN_LEFT); // if (flag) // do this only if there is a width
// SetAlignment(cell, LYX_ALIGN_LEFT);
for (int i = 0; i < rows_; ++i) { for (int i = 0; i < rows_; ++i) {
int c = GetCellNumber(i, j); int c = GetCellNumber(i, j);
flag = !GetPWidth(c).zero(); // because of multicolumns! flag = !GetPWidth(c).zero(); // because of multicolumns!
@ -2212,7 +2213,7 @@ int LyXTabular::TeXRow(ostream & os, int const i, Buffer const * buf,
} }
++cell; ++cell;
} }
os << "\\\\\n"; os << "\\tabularnewline\n";
++ret; ++ret;
ret += TeXBottomHLine(os, i); ret += TeXBottomHLine(os, i);
return ret; return ret;
@ -2243,6 +2244,20 @@ int LyXTabular::latex(Buffer const * buf,
if (column_info[i].left_line) if (column_info[i].left_line)
os << '|'; os << '|';
if (!column_info[i].p_width.zero()) { if (!column_info[i].p_width.zero()) {
os << ">{";
switch (column_info[i].alignment) {
case LYX_ALIGN_LEFT:
os << "\\raggedright";
break;
case LYX_ALIGN_RIGHT:
os << "\\raggedleft";
break;
case LYX_ALIGN_CENTER:
os << "\\centering";
break;
}
os << "}";
switch (column_info[i].valignment) { switch (column_info[i].valignment) {
case LYX_VALIGN_TOP: case LYX_VALIGN_TOP:
os << "p"; os << "p";
@ -2722,12 +2737,15 @@ int LyXTabular::GetCellFromInset(Inset const * inset, int maybe_cell) const
void LyXTabular::Validate(LaTeXFeatures & features) const void LyXTabular::Validate(LaTeXFeatures & features) const
{ {
features.require("NeedTabularnewline");
if (IsLongTabular()) if (IsLongTabular())
features.require("longtable"); features.require("longtable");
if (NeedRotating()) if (NeedRotating())
features.require("rotating"); features.require("rotating");
for (int cell = 0; cell < numberofcells; ++cell) { for (int cell = 0; cell < numberofcells; ++cell) {
if (GetVAlignment(cell) != LYX_VALIGN_TOP) if ( (GetVAlignment(cell) != LYX_VALIGN_TOP) ||
( !(GetPWidth(cell).zero())&&!(IsMultiColumn(cell)) )
)
features.require("array"); features.require("array");
GetCellInset(cell)->validate(features); GetCellInset(cell)->validate(features);
} }