From a981100a91cfd2ba76019a4b7ba23cd6cbdde7ad Mon Sep 17 00:00:00 2001 From: Dekel Tsur Date: Thu, 21 Nov 2002 12:24:50 +0000 Subject: [PATCH] Support for block alignment in fixed width columns. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5690 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 5 +++ src/frontends/xforms/FormTabular.C | 8 ++++- src/frontends/xforms/forms/form_tabular.fd | 42 +++++++++++++++------- src/insets/ChangeLog | 5 +++ src/insets/insettabular.C | 16 +++++++++ src/tabular.C | 8 ++--- src/tabular.h | 2 ++ 7 files changed, 68 insertions(+), 18 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index af15a4c52b..5877cb65c2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2002-11-21 Dekel Tsur + + * tabular.C (latex): Support for block alignment in fixed width + columns. + 2002-11-17 John Levon * BufferView_pimpl.C: diff --git a/src/frontends/xforms/FormTabular.C b/src/frontends/xforms/FormTabular.C index ec3e0de919..0e75b87006 100644 --- a/src/frontends/xforms/FormTabular.C +++ b/src/frontends/xforms/FormTabular.C @@ -315,12 +315,15 @@ void FormTabular::update() 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 + else if (align == LYX_ALIGN_CENTER) fl_set_button(column_options_->radio_align_center, 1); + else + 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); @@ -335,6 +338,7 @@ void FormTabular::update() 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_center, !pwidth.zero()); @@ -582,6 +586,8 @@ ButtonPolicy::SMInput FormTabular::input(FL_OBJECT * ob, long) 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) diff --git a/src/frontends/xforms/forms/form_tabular.fd b/src/frontends/xforms/forms/form_tabular.fd index f5f1361a00..4a1c7c084d 100644 --- a/src/frontends/xforms/forms/form_tabular.fd +++ b/src/frontends/xforms/forms/form_tabular.fd @@ -311,7 +311,7 @@ argument: Name: form_tabular_column Width: 505 Height: 225 -Number of Objects: 23 +Number of Objects: 24 -------------------- class: FL_BOX @@ -496,7 +496,7 @@ argument: 0 -------------------- class: FL_BEGIN_GROUP type: 0 -box: 0 0 0 0 +box: 0 10 10 0 boxtype: FL_NO_BOX colors: FL_COL1 FL_MCOL alignment: FL_ALIGN_CENTER @@ -507,14 +507,14 @@ label: shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity -name: +name: callback: argument: -------------------- class: FL_ROUND3DBUTTON type: RADIO_BUTTON -box: 205 35 105 25 +box: 205 25 105 25 boxtype: FL_NO_BOX colors: FL_COL1 FL_YELLOW alignment: FL_ALIGN_CENTER @@ -533,7 +533,7 @@ argument: 0 -------------------- class: FL_ROUND3DBUTTON type: RADIO_BUTTON -box: 205 85 105 25 +box: 205 75 105 25 boxtype: FL_NO_BOX colors: FL_COL1 FL_YELLOW alignment: FL_ALIGN_CENTER @@ -551,7 +551,7 @@ argument: 0 -------------------- class: FL_ROUND3DBUTTON type: RADIO_BUTTON -box: 205 60 105 25 +box: 205 50 105 25 boxtype: FL_NO_BOX colors: FL_COL1 FL_YELLOW alignment: FL_ALIGN_CENTER @@ -587,7 +587,7 @@ argument: -------------------- class: FL_BEGIN_GROUP type: 0 -box: 0 0 0 0 +box: 0 10 10 0 boxtype: FL_NO_BOX colors: FL_COL1 FL_MCOL alignment: FL_ALIGN_CENTER @@ -598,7 +598,7 @@ label: shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity -name: +name: callback: argument: @@ -729,6 +729,24 @@ name: callback: argument: +-------------------- +class: FL_ROUND3DBUTTON +type: RADIO_BUTTON +box: 205 100 105 25 +boxtype: FL_NO_BOX +colors: FL_COL1 FL_YELLOW +alignment: FL_ALIGN_CENTER +style: FL_NORMAL_STYLE +size: FL_NORMAL_SIZE +lcol: FL_BLACK +label: Block|#k +shortcut: +resize: FL_RESIZE_ALL +gravity: FL_NoGravity FL_NoGravity +name: radio_align_block +callback: C_FormBaseInputCB +argument: 0 + =============== FORM =============== Name: form_tabular_cell Width: 505 @@ -918,7 +936,7 @@ argument: 0 -------------------- class: FL_BEGIN_GROUP type: 0 -box: 0 0 0 0 +box: 0 10 10 0 boxtype: FL_NO_BOX colors: FL_COL1 FL_MCOL alignment: FL_ALIGN_CENTER @@ -929,7 +947,7 @@ label: shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity -name: +name: callback: argument: @@ -1009,7 +1027,7 @@ argument: -------------------- class: FL_BEGIN_GROUP type: 0 -box: 0 0 0 0 +box: 0 10 10 0 boxtype: FL_NO_BOX colors: FL_COL1 FL_MCOL alignment: FL_ALIGN_CENTER @@ -1020,7 +1038,7 @@ label: shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity -name: +name: callback: argument: diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 89ff090328..3b59b6bd2f 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,8 @@ +2002-11-21 Dekel Tsur + + * insettabular.C (tabularFeatures): Support for block alignment in fixed width + columns. + 2002-11-20 Juergen Vigna * insettabular.C (resetPos): temporary fix for endless loop in diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 18ecdb2916..e79251d301 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -86,6 +86,7 @@ TabularFeature tabularFeature[] = { LyXTabular::ALIGN_LEFT, "align-left" }, { LyXTabular::ALIGN_RIGHT, "align-right" }, { LyXTabular::ALIGN_CENTER, "align-center" }, + { LyXTabular::ALIGN_BLOCK, "align-block" }, { LyXTabular::VALIGN_TOP, "valign-top" }, { LyXTabular::VALIGN_BOTTOM, "valign-bottom" }, { LyXTabular::VALIGN_CENTER, "valign-center" }, @@ -1880,6 +1881,9 @@ void InsetTabular::tabularFeatures(BufferView * bv, case LyXTabular::ALIGN_CENTER: setAlign = LYX_ALIGN_CENTER; break; + case LyXTabular::ALIGN_BLOCK: + setAlign = LYX_ALIGN_BLOCK; + break; case LyXTabular::M_VALIGN_TOP: case LyXTabular::VALIGN_TOP: setVAlign = LyXTabular::LYX_VALIGN_TOP; @@ -1926,6 +1930,13 @@ void InsetTabular::tabularFeatures(BufferView * bv, } updateLocal(bv, INIT, true); } + + if (vallen.zero() + && tabular->GetAlignment(actcell, true) == LYX_ALIGN_BLOCK) + tabularFeatures(bv, LyXTabular::ALIGN_CENTER, string()); + else if (!vallen.zero() + && tabular->GetAlignment(actcell, true) != LYX_ALIGN_BLOCK) + tabularFeatures(bv, LyXTabular::ALIGN_BLOCK, string()); } break; case LyXTabular::SET_MPWIDTH: @@ -2050,6 +2061,7 @@ void InsetTabular::tabularFeatures(BufferView * bv, case LyXTabular::ALIGN_LEFT: case LyXTabular::ALIGN_RIGHT: case LyXTabular::ALIGN_CENTER: + case LyXTabular::ALIGN_BLOCK: for (int i = sel_row_start; i <= sel_row_end; ++i) for (int j = sel_col_start; j <= sel_col_end; ++j) tabular->SetAlignment( @@ -2420,6 +2432,10 @@ FuncStatus InsetTabular::getStatus(string const & what) const case LyXTabular::ALIGN_CENTER: status.setOnOff(tabular->GetAlignment(actcell, flag) == LYX_ALIGN_CENTER); break; + case LyXTabular::ALIGN_BLOCK: + status.disabled(tabular->GetPWidth(actcell).zero()); + status.setOnOff(tabular->GetAlignment(actcell, flag) == LYX_ALIGN_BLOCK); + break; case LyXTabular::M_VALIGN_TOP: flag = false; case LyXTabular::VALIGN_TOP: diff --git a/src/tabular.C b/src/tabular.C index 74c9caa17e..519813af97 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -2244,19 +2244,17 @@ int LyXTabular::latex(Buffer const * buf, if (column_info[i].left_line) os << '|'; if (!column_info[i].p_width.zero()) { - os << ">{"; switch (column_info[i].alignment) { case LYX_ALIGN_LEFT: - os << "\\raggedright"; + os << ">{\\raggedright}"; break; case LYX_ALIGN_RIGHT: - os << "\\raggedleft"; + os << ">{\\raggedleft}"; break; case LYX_ALIGN_CENTER: - os << "\\centering"; + os << ">{\\centering}"; break; } - os << "}"; switch (column_info[i].valignment) { case LYX_VALIGN_TOP: diff --git a/src/tabular.h b/src/tabular.h index 09e0faa1f7..2b34120c85 100644 --- a/src/tabular.h +++ b/src/tabular.h @@ -61,6 +61,8 @@ public: /// ALIGN_CENTER, /// + ALIGN_BLOCK, + /// VALIGN_TOP, /// VALIGN_BOTTOM,