-
- // set the position for the vertical alignment
- // if the cell is not the highest, align it according to the row valignment
- // and according to its own valignment
- // Note: The fractions of the scent values were found by testing
- // there is no bettwer way for the calculation because of LyX's definition
- // of ascent and descent. The correct way would be to calculate based
- // on the text height, the line space and paragraph separation.
- cy = y;
- if (tabular.cell_info[r][c].height < tabular.row_info[r].maxheight) {
- switch (tabular.row_info[r].valignment) {
- case Tabular::LYX_VALIGN_TOP:
- switch (tabular.getVAlignment(idx)) {
- case Tabular::LYX_VALIGN_TOP:
- break;
- case Tabular::LYX_VALIGN_MIDDLE:
- cy += - tabular.cell_info[r][c].descent / 2
- + 0.3 * tabular.cell_info[r][c].ascent;
- // FIXME the row also needs to be increased at the upper border
- break;
- case Tabular::LYX_VALIGN_BOTTOM:
- cy += - tabular.cell_info[r][c].descent
- + 0.6 * tabular.cell_info[r][c].ascent;
- // FIXME the row also needs to be increased at the upper border
- break;
- }
- break;
- case Tabular::LYX_VALIGN_MIDDLE:
- switch (tabular.getVAlignment(idx)) {
- case Tabular::LYX_VALIGN_TOP:
- cy += tabular.row_info[r].maxheight / 2
- - 0.75 * tabular.cell_info[r][c].ascent;
- break;
- case Tabular::LYX_VALIGN_MIDDLE:
- cy += tabular.row_info[r].maxheight / 2
- - tabular.cell_info[r][c].descent / 2
- - 0.5 * tabular.cell_info[r][c].ascent;
- break;
- case Tabular::LYX_VALIGN_BOTTOM:
- cy += tabular.row_info[r].maxheight / 2
- - tabular.cell_info[r][c].descent
- - 0.2 * tabular.cell_info[r][c].ascent;
- break;
- }
- break;
- case Tabular::LYX_VALIGN_BOTTOM:
- switch (tabular.getVAlignment(idx)) {
- case Tabular::LYX_VALIGN_TOP:
- cy += tabular.row_info[r].maxheight
- - 1.5 * tabular.cell_info[r][c].ascent;
- break;
- case Tabular::LYX_VALIGN_MIDDLE:
- cy += tabular.row_info[r].maxheight
- - tabular.cell_info[r][c].descent / 2
- - 1.2 * tabular.cell_info[r][c].ascent;
- // FIXME the row also needs to be increased at the lower border
- break;
- case Tabular::LYX_VALIGN_BOTTOM:
- cy += tabular.row_info[r].maxheight
- - tabular.cell_info[r][c].descent
- - 0.9 * tabular.cell_info[r][c].ascent;
- // FIXME the row also needs to be increased at the lower border
- break;
- }
- break;
- }
- }
-