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
This commit is contained in:
Dekel Tsur 2002-11-21 12:24:50 +00:00
parent 8903a92aea
commit a981100a91
7 changed files with 68 additions and 18 deletions

View File

@ -1,3 +1,8 @@
2002-11-21 Dekel Tsur <dekelts@tau.ac.il>
* tabular.C (latex): Support for block alignment in fixed width
columns.
2002-11-17 John Levon <levon@movementarian.org> 2002-11-17 John Levon <levon@movementarian.org>
* BufferView_pimpl.C: * BufferView_pimpl.C:

View File

@ -315,12 +315,15 @@ 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);
fl_set_button(column_options_->radio_align_block, 0);
if (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);
else else if (align == LYX_ALIGN_CENTER)
fl_set_button(column_options_->radio_align_center, 1); fl_set_button(column_options_->radio_align_center, 1);
else
fl_set_button(column_options_->radio_align_block, 1);
align = tabular->GetVAlignment(cell, true); align = tabular->GetVAlignment(cell, true);
fl_set_button(column_options_->radio_valign_top, 0); 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_bottom, 0);
@ -335,6 +338,7 @@ void FormTabular::update()
setEnabled(column_options_->radio_align_left, true); setEnabled(column_options_->radio_align_left, true);
setEnabled(column_options_->radio_align_right, true); setEnabled(column_options_->radio_align_right, true);
setEnabled(column_options_->radio_align_center, 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_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());
@ -582,6 +586,8 @@ ButtonPolicy::SMInput FormTabular::input(FL_OBJECT * ob, long)
num = LyXTabular::ALIGN_RIGHT; num = LyXTabular::ALIGN_RIGHT;
else if (ob == column_options_->radio_align_center) else if (ob == column_options_->radio_align_center)
num = LyXTabular::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) else if (ob == column_options_->radio_valign_top)
num = LyXTabular::VALIGN_TOP; num = LyXTabular::VALIGN_TOP;
else if (ob == column_options_->radio_valign_bottom) else if (ob == column_options_->radio_valign_bottom)

View File

@ -311,7 +311,7 @@ argument:
Name: form_tabular_column Name: form_tabular_column
Width: 505 Width: 505
Height: 225 Height: 225
Number of Objects: 23 Number of Objects: 24
-------------------- --------------------
class: FL_BOX class: FL_BOX
@ -496,7 +496,7 @@ argument: 0
-------------------- --------------------
class: FL_BEGIN_GROUP class: FL_BEGIN_GROUP
type: 0 type: 0
box: 0 0 0 0 box: 0 10 10 0
boxtype: FL_NO_BOX boxtype: FL_NO_BOX
colors: FL_COL1 FL_MCOL colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_CENTER alignment: FL_ALIGN_CENTER
@ -507,14 +507,14 @@ label:
shortcut: shortcut:
resize: FL_RESIZE_ALL resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity gravity: FL_NoGravity FL_NoGravity
name: name:
callback: callback:
argument: argument:
-------------------- --------------------
class: FL_ROUND3DBUTTON class: FL_ROUND3DBUTTON
type: RADIO_BUTTON type: RADIO_BUTTON
box: 205 35 105 25 box: 205 25 105 25
boxtype: FL_NO_BOX boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER alignment: FL_ALIGN_CENTER
@ -533,7 +533,7 @@ argument: 0
-------------------- --------------------
class: FL_ROUND3DBUTTON class: FL_ROUND3DBUTTON
type: RADIO_BUTTON type: RADIO_BUTTON
box: 205 85 105 25 box: 205 75 105 25
boxtype: FL_NO_BOX boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER alignment: FL_ALIGN_CENTER
@ -551,7 +551,7 @@ argument: 0
-------------------- --------------------
class: FL_ROUND3DBUTTON class: FL_ROUND3DBUTTON
type: RADIO_BUTTON type: RADIO_BUTTON
box: 205 60 105 25 box: 205 50 105 25
boxtype: FL_NO_BOX boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER alignment: FL_ALIGN_CENTER
@ -587,7 +587,7 @@ argument:
-------------------- --------------------
class: FL_BEGIN_GROUP class: FL_BEGIN_GROUP
type: 0 type: 0
box: 0 0 0 0 box: 0 10 10 0
boxtype: FL_NO_BOX boxtype: FL_NO_BOX
colors: FL_COL1 FL_MCOL colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_CENTER alignment: FL_ALIGN_CENTER
@ -598,7 +598,7 @@ label:
shortcut: shortcut:
resize: FL_RESIZE_ALL resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity gravity: FL_NoGravity FL_NoGravity
name: name:
callback: callback:
argument: argument:
@ -729,6 +729,24 @@ name:
callback: callback:
argument: 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 =============== =============== FORM ===============
Name: form_tabular_cell Name: form_tabular_cell
Width: 505 Width: 505
@ -918,7 +936,7 @@ argument: 0
-------------------- --------------------
class: FL_BEGIN_GROUP class: FL_BEGIN_GROUP
type: 0 type: 0
box: 0 0 0 0 box: 0 10 10 0
boxtype: FL_NO_BOX boxtype: FL_NO_BOX
colors: FL_COL1 FL_MCOL colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_CENTER alignment: FL_ALIGN_CENTER
@ -929,7 +947,7 @@ label:
shortcut: shortcut:
resize: FL_RESIZE_ALL resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity gravity: FL_NoGravity FL_NoGravity
name: name:
callback: callback:
argument: argument:
@ -1009,7 +1027,7 @@ argument:
-------------------- --------------------
class: FL_BEGIN_GROUP class: FL_BEGIN_GROUP
type: 0 type: 0
box: 0 0 0 0 box: 0 10 10 0
boxtype: FL_NO_BOX boxtype: FL_NO_BOX
colors: FL_COL1 FL_MCOL colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_CENTER alignment: FL_ALIGN_CENTER
@ -1020,7 +1038,7 @@ label:
shortcut: shortcut:
resize: FL_RESIZE_ALL resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity gravity: FL_NoGravity FL_NoGravity
name: name:
callback: callback:
argument: argument:

View File

@ -1,3 +1,8 @@
2002-11-21 Dekel Tsur <dekelts@tau.ac.il>
* insettabular.C (tabularFeatures): Support for block alignment in fixed width
columns.
2002-11-20 Juergen Vigna <jug@sad.it> 2002-11-20 Juergen Vigna <jug@sad.it>
* insettabular.C (resetPos): temporary fix for endless loop in * insettabular.C (resetPos): temporary fix for endless loop in

View File

@ -86,6 +86,7 @@ TabularFeature tabularFeature[] =
{ LyXTabular::ALIGN_LEFT, "align-left" }, { LyXTabular::ALIGN_LEFT, "align-left" },
{ LyXTabular::ALIGN_RIGHT, "align-right" }, { LyXTabular::ALIGN_RIGHT, "align-right" },
{ LyXTabular::ALIGN_CENTER, "align-center" }, { LyXTabular::ALIGN_CENTER, "align-center" },
{ LyXTabular::ALIGN_BLOCK, "align-block" },
{ LyXTabular::VALIGN_TOP, "valign-top" }, { LyXTabular::VALIGN_TOP, "valign-top" },
{ LyXTabular::VALIGN_BOTTOM, "valign-bottom" }, { LyXTabular::VALIGN_BOTTOM, "valign-bottom" },
{ LyXTabular::VALIGN_CENTER, "valign-center" }, { LyXTabular::VALIGN_CENTER, "valign-center" },
@ -1880,6 +1881,9 @@ void InsetTabular::tabularFeatures(BufferView * bv,
case LyXTabular::ALIGN_CENTER: case LyXTabular::ALIGN_CENTER:
setAlign = LYX_ALIGN_CENTER; setAlign = LYX_ALIGN_CENTER;
break; break;
case LyXTabular::ALIGN_BLOCK:
setAlign = LYX_ALIGN_BLOCK;
break;
case LyXTabular::M_VALIGN_TOP: case LyXTabular::M_VALIGN_TOP:
case LyXTabular::VALIGN_TOP: case LyXTabular::VALIGN_TOP:
setVAlign = LyXTabular::LYX_VALIGN_TOP; setVAlign = LyXTabular::LYX_VALIGN_TOP;
@ -1926,6 +1930,13 @@ void InsetTabular::tabularFeatures(BufferView * bv,
} }
updateLocal(bv, INIT, true); 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; break;
case LyXTabular::SET_MPWIDTH: case LyXTabular::SET_MPWIDTH:
@ -2050,6 +2061,7 @@ void InsetTabular::tabularFeatures(BufferView * bv,
case LyXTabular::ALIGN_LEFT: case LyXTabular::ALIGN_LEFT:
case LyXTabular::ALIGN_RIGHT: case LyXTabular::ALIGN_RIGHT:
case LyXTabular::ALIGN_CENTER: case LyXTabular::ALIGN_CENTER:
case LyXTabular::ALIGN_BLOCK:
for (int i = sel_row_start; i <= sel_row_end; ++i) for (int i = sel_row_start; i <= sel_row_end; ++i)
for (int j = sel_col_start; j <= sel_col_end; ++j) for (int j = sel_col_start; j <= sel_col_end; ++j)
tabular->SetAlignment( tabular->SetAlignment(
@ -2420,6 +2432,10 @@ FuncStatus InsetTabular::getStatus(string const & what) const
case LyXTabular::ALIGN_CENTER: case LyXTabular::ALIGN_CENTER:
status.setOnOff(tabular->GetAlignment(actcell, flag) == LYX_ALIGN_CENTER); status.setOnOff(tabular->GetAlignment(actcell, flag) == LYX_ALIGN_CENTER);
break; 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: case LyXTabular::M_VALIGN_TOP:
flag = false; flag = false;
case LyXTabular::VALIGN_TOP: case LyXTabular::VALIGN_TOP:

View File

@ -2244,19 +2244,17 @@ 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) { switch (column_info[i].alignment) {
case LYX_ALIGN_LEFT: case LYX_ALIGN_LEFT:
os << "\\raggedright"; os << ">{\\raggedright}";
break; break;
case LYX_ALIGN_RIGHT: case LYX_ALIGN_RIGHT:
os << "\\raggedleft"; os << ">{\\raggedleft}";
break; break;
case LYX_ALIGN_CENTER: case LYX_ALIGN_CENTER:
os << "\\centering"; os << ">{\\centering}";
break; break;
} }
os << "}";
switch (column_info[i].valignment) { switch (column_info[i].valignment) {
case LYX_VALIGN_TOP: case LYX_VALIGN_TOP:

View File

@ -61,6 +61,8 @@ public:
/// ///
ALIGN_CENTER, ALIGN_CENTER,
/// ///
ALIGN_BLOCK,
///
VALIGN_TOP, VALIGN_TOP,
/// ///
VALIGN_BOTTOM, VALIGN_BOTTOM,