mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 02:14:50 +00:00
More fixes to various bug reports.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2453 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
e454df24f5
commit
86e4a9bc8a
@ -407,7 +407,7 @@ bool BufferView::lockInset(UpdatableInset * inset)
|
||||
|
||||
void BufferView::showLockedInsetCursor(int x, int y, int asc, int desc)
|
||||
{
|
||||
if (theLockingInset() && available()) {
|
||||
if (available() && theLockingInset()) {
|
||||
LyXCursor cursor = text->cursor;
|
||||
if ((cursor.pos() - 1 >= 0) &&
|
||||
(cursor.par()->getChar(cursor.pos() - 1) ==
|
||||
|
@ -1,3 +1,12 @@
|
||||
2001-08-08 Juergen Vigna <jug@sad.it>
|
||||
|
||||
* tabular.C (SetWidthOfCell): fixed special case where the width
|
||||
was not updated!
|
||||
(LeftLine): handle '|' in align_special.
|
||||
(RightLine): ditto
|
||||
(LeftAlreadyDrawed): ditto
|
||||
(SetWidthOfCell): ditto
|
||||
|
||||
2001-08-07 Juergen Vigna <jug@sad.it>
|
||||
|
||||
* lyx_main.C (readUIFile): fixed some forgotten lowercase!
|
||||
|
@ -1,3 +1,23 @@
|
||||
2001-08-08 Juergen Vigna <jug@sad.it>
|
||||
|
||||
* insettabular.C (setPos): fixed wrong actrow < rows() check.
|
||||
|
||||
* insettext.C (insetUnlock): remove double-space on inset unlock.
|
||||
|
||||
* insetcollapsable.C (draw): fix returned x when label > inset-width.
|
||||
|
||||
* insettabular.C (update): fixed cursor positon after an insert.
|
||||
(insetAllowed): do not allow to insert insets when not inside the
|
||||
inset!
|
||||
(draw): clear below an inset too as it could have changed height.
|
||||
|
||||
* inset.C (getMaxWidth): fixed width for inset in inset.
|
||||
|
||||
* insettext.C (update): small fix.
|
||||
|
||||
* insettabular.C (tabularFeatures): added selection support to
|
||||
DELETE_ROW/DELETE_COLUMN.
|
||||
|
||||
2001-08-07 Juergen Vigna <jug@sad.it>
|
||||
|
||||
* inset.C (getMaxWidth): recoded and all it's implementations!
|
||||
|
@ -320,11 +320,6 @@ int UpdatableInset::getMaxWidth(BufferView * bv, UpdatableInset const *) const
|
||||
if (w < 0) {
|
||||
return -1;
|
||||
}
|
||||
if (owner()) {
|
||||
if (topx_set) // this makes only sense if we have a top_x
|
||||
w = w - top_x + owner()->x();
|
||||
return w;
|
||||
}
|
||||
// check for margins left/right and extra right margin "const 5"
|
||||
if ((w - ((2 * TEXT_TO_INSET_OFFSET) + 5)) >= 0)
|
||||
w -= (2 * TEXT_TO_INSET_OFFSET) + 5;
|
||||
@ -333,6 +328,9 @@ int UpdatableInset::getMaxWidth(BufferView * bv, UpdatableInset const *) const
|
||||
w = 10; // minimum I require!!!
|
||||
} else {
|
||||
w -= top_x;
|
||||
if (owner()) {
|
||||
w += owner()->x();
|
||||
}
|
||||
}
|
||||
} else if (w < 10) {
|
||||
w = 10;
|
||||
|
@ -226,6 +226,8 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
|
||||
inset.draw(bv, f,
|
||||
bl + descent_collapsed() + inset.ascent(bv, f),
|
||||
x, cleared);
|
||||
if (x < (top_x + button_length + TEXT_TO_INSET_OFFSET))
|
||||
x = top_x + button_length + TEXT_TO_INSET_OFFSET;
|
||||
}
|
||||
|
||||
|
||||
|
@ -249,7 +249,8 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
|
||||
x += static_cast<float>(scroll());
|
||||
#endif
|
||||
if (!cleared && ((need_update == INIT) || (need_update == FULL) ||
|
||||
(top_x != int(x)) || (top_baseline != baseline))) {
|
||||
(top_x != int(x)) || (top_baseline != baseline)))
|
||||
{
|
||||
int h = ascent(bv, font) + descent(bv, font);
|
||||
int const tx = display() || !owner() ? 0 : top_x;
|
||||
int w = tx ? width(bv, font) : pain.paperWidth();
|
||||
@ -314,11 +315,12 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
|
||||
Inset * inset = tabular->GetCellInset(cell);
|
||||
for (i = 0;
|
||||
inset != the_locking_inset && i < tabular->rows();
|
||||
++i) {
|
||||
++i)
|
||||
{
|
||||
for (j = 0;
|
||||
inset != the_locking_inset
|
||||
&& j < tabular->columns();
|
||||
++j) {
|
||||
inset != the_locking_inset && j < tabular->columns();
|
||||
++j)
|
||||
{
|
||||
if (tabular->IsPartOfMultiColumn(i, j))
|
||||
continue;
|
||||
nx += tabular->GetWidthOfColumn(cell);
|
||||
@ -355,14 +357,9 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
|
||||
}
|
||||
float dx = nx + tabular->GetBeginningOfTextInCell(cell);
|
||||
float cx = dx;
|
||||
//cx = dx = nx + tabular->GetBeginningOfTextInCell(cell);
|
||||
tabular->GetCellInset(cell)->draw(bv, font, baseline, dx, false);
|
||||
#if 0
|
||||
if (bv->text->status == LyXText::CHANGED_IN_DRAW)
|
||||
return;
|
||||
#endif
|
||||
// clear only if we didn't have a change
|
||||
if (need_update == CELL) {
|
||||
if (bv->text->status() != LyXText::CHANGED_IN_DRAW) {
|
||||
// clear before the inset
|
||||
pain.fillRectangle(
|
||||
nx + 1,
|
||||
@ -382,6 +379,18 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
|
||||
tabular->GetAscentOfRow(i) +
|
||||
tabular->GetDescentOfRow(i) - 1,
|
||||
backgroundColor());
|
||||
// clear below the inset
|
||||
pain.fillRectangle(
|
||||
nx + 1,
|
||||
baseline + the_locking_inset->descent(bv, font) + 1,
|
||||
tabular->GetWidthOfColumn(cell) -
|
||||
tabular->GetAdditionalWidth(cell) - 1,
|
||||
tabular->GetAscentOfRow(i) +
|
||||
tabular->GetDescentOfRow(i) -
|
||||
the_locking_inset->ascent(bv, font) -
|
||||
the_locking_inset->descent(bv, font) -
|
||||
TEXT_TO_INSET_OFFSET - 1,
|
||||
backgroundColor());
|
||||
}
|
||||
}
|
||||
x -= ADD_TO_TABULAR_WIDTH;
|
||||
@ -461,7 +470,9 @@ void InsetTabular::drawCellSelection(Painter & pain, int x, int baseline,
|
||||
void InsetTabular::update(BufferView * bv, LyXFont const & font, bool reinit)
|
||||
{
|
||||
if (in_update) {
|
||||
if (reinit && owner()) {
|
||||
if (reinit) {
|
||||
resetPos(bv);
|
||||
if (owner())
|
||||
owner()->update(bv, font, true);
|
||||
}
|
||||
return;
|
||||
@ -469,7 +480,8 @@ void InsetTabular::update(BufferView * bv, LyXFont const & font, bool reinit)
|
||||
in_update = true;
|
||||
if (reinit) {
|
||||
need_update = INIT;
|
||||
calculate_dimensions_of_cells(bv, font, true);
|
||||
if (calculate_dimensions_of_cells(bv, font, true))
|
||||
resetPos(bv);
|
||||
if (owner())
|
||||
owner()->update(bv, font, true);
|
||||
in_update = false;
|
||||
@ -596,14 +608,10 @@ bool InsetTabular::lockInsetInInset(BufferView * bv, UpdatableInset * inset)
|
||||
lyxerr[Debug::INSETS] << "OK" << endl;
|
||||
the_locking_inset = tabular->GetCellInset(actcell);
|
||||
resetPos(bv);
|
||||
inset_x = cursor_.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
|
||||
inset_y = cursor_.y();
|
||||
return true;
|
||||
} else if (the_locking_inset && (the_locking_inset == inset)) {
|
||||
lyxerr[Debug::INSETS] << "OK" << endl;
|
||||
resetPos(bv);
|
||||
inset_x = cursor_.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
|
||||
inset_y = cursor_.y();
|
||||
} else if (the_locking_inset) {
|
||||
lyxerr[Debug::INSETS] << "MAYBE" << endl;
|
||||
return the_locking_inset->lockInsetInInset(bv, inset);
|
||||
@ -1180,9 +1188,6 @@ bool InsetTabular::calculate_dimensions_of_cells(BufferView * bv,
|
||||
changed = tabular->SetDescentOfRow(actrow, maxDesc + ADD_TO_HEIGHT) || changed;
|
||||
return changed;
|
||||
}
|
||||
#if 0
|
||||
cur_cell = -1;
|
||||
#endif
|
||||
for (int i = 0; i < tabular->rows(); ++i) {
|
||||
maxAsc = 0;
|
||||
maxDesc = 0;
|
||||
@ -1281,7 +1286,7 @@ void InsetTabular::setPos(BufferView * bv, int x, int y) const
|
||||
int ly = tabular->GetDescentOfRow(actrow);
|
||||
|
||||
// first search the right row
|
||||
while((ly < y) && (actrow < tabular->rows())) {
|
||||
while((ly < y) && ((actrow+1) < tabular->rows())) {
|
||||
cursor_.y(cursor_.y() + tabular->GetDescentOfRow(actrow) +
|
||||
tabular->GetAscentOfRow(actrow + 1) +
|
||||
tabular->GetAdditionalHeight(actrow + 1));
|
||||
@ -1293,22 +1298,10 @@ void InsetTabular::setPos(BufferView * bv, int x, int y) const
|
||||
// now search the right column
|
||||
int lx = tabular->GetWidthOfColumn(actcell) -
|
||||
tabular->GetAdditionalWidth(actcell);
|
||||
#if 0
|
||||
#ifdef WITH_WARNINGS
|
||||
#warning Jürgen, can you rewrite this to _not_ use the sequencing operator. (Lgb)
|
||||
#endif
|
||||
for (; !tabular->IsLastCellInRow(actcell) && (lx < x);
|
||||
++actcell,lx += tabular->GetWidthOfColumn(actcell) +
|
||||
tabular->GetAdditionalWidth(actcell - 1));
|
||||
#else
|
||||
// Jürgen, you should check that this is correct. (Lgb)
|
||||
#warning Jürgen, please check. (Lgb)
|
||||
for (; !tabular->IsLastCellInRow(actcell) && lx < x; ++actcell) {
|
||||
lx += tabular->GetWidthOfColumn(actcell + 1)
|
||||
+ tabular->GetAdditionalWidth(actcell);
|
||||
}
|
||||
|
||||
#endif
|
||||
cursor_.x(lx - tabular->GetWidthOfColumn(actcell) + top_x + 2);
|
||||
resetPos(bv);
|
||||
}
|
||||
@ -1384,6 +1377,10 @@ void InsetTabular::resetPos(BufferView * bv) const
|
||||
scroll(bv, old_x - cursor_.x());
|
||||
updateLocal(bv, FULL, false);
|
||||
}
|
||||
if (the_locking_inset) {
|
||||
inset_x = cursor_.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
|
||||
inset_y = cursor_.y();
|
||||
}
|
||||
if ((!the_locking_inset ||
|
||||
!the_locking_inset->getFirstLockingInsetOfType(TABULAR_CODE)) &&
|
||||
actcell != oldcell) {
|
||||
@ -1675,6 +1672,7 @@ void InsetTabular::tabularFeatures(BufferView * bv,
|
||||
case LyXTabular::SET_SPECIAL_COLUMN:
|
||||
case LyXTabular::SET_SPECIAL_MULTI:
|
||||
tabular->SetAlignSpecial(actcell,value,feature);
|
||||
updateLocal(bv, FULL, true);
|
||||
break;
|
||||
case LyXTabular::APPEND_ROW:
|
||||
// append the row into the tabular
|
||||
@ -1691,19 +1689,23 @@ void InsetTabular::tabularFeatures(BufferView * bv,
|
||||
break;
|
||||
case LyXTabular::DELETE_ROW:
|
||||
unlockInsetInInset(bv, the_locking_inset);
|
||||
tabular->DeleteRow(tabular->row_of_cell(actcell));
|
||||
if ((row+1) > tabular->rows())
|
||||
--row;
|
||||
actcell = tabular->GetCellNumber(row, column);
|
||||
for(int i = sel_row_start; i <= sel_row_end; ++i) {
|
||||
tabular->DeleteRow(sel_row_start);
|
||||
}
|
||||
if ((sel_row_start) > tabular->rows())
|
||||
--sel_row_start;
|
||||
actcell = tabular->GetCellNumber(sel_row_start, column);
|
||||
clearSelection();
|
||||
updateLocal(bv, INIT, true);
|
||||
break;
|
||||
case LyXTabular::DELETE_COLUMN:
|
||||
unlockInsetInInset(bv, the_locking_inset);
|
||||
tabular->DeleteColumn(tabular->column_of_cell(actcell));
|
||||
if ((column+1) > tabular->columns())
|
||||
--column;
|
||||
actcell = tabular->GetCellNumber(row, column);
|
||||
for(int i = sel_col_start; i <= sel_col_end; ++i) {
|
||||
tabular->DeleteColumn(sel_col_start);
|
||||
}
|
||||
if ((sel_col_start+1) > tabular->columns())
|
||||
--sel_col_start;
|
||||
actcell = tabular->GetCellNumber(row, sel_col_start);
|
||||
clearSelection();
|
||||
updateLocal(bv, INIT, true);
|
||||
break;
|
||||
@ -2596,3 +2598,11 @@ bool InsetTabular::searchBackward(BufferView * bv, string const & str,
|
||||
return searchBackward(bv, str, cs, mw);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool InsetTabular::insetAllowed(Inset::Code code) const
|
||||
{
|
||||
if (the_locking_inset)
|
||||
return the_locking_inset->insetAllowed(code);
|
||||
return false;
|
||||
}
|
||||
|
@ -125,9 +125,7 @@ public:
|
||||
///
|
||||
bool insertInset(BufferView *, Inset *);
|
||||
///
|
||||
bool insetAllowed(Inset::Code) const {
|
||||
return the_locking_inset != 0;
|
||||
}
|
||||
bool insetAllowed(Inset::Code code) const;
|
||||
///
|
||||
bool isTextInset() const { return true; }
|
||||
///
|
||||
|
@ -515,6 +515,7 @@ void InsetText::update(BufferView * bv, LyXFont const & font, bool reinit)
|
||||
{
|
||||
if (in_update) {
|
||||
if (reinit && owner()) {
|
||||
reinitLyXText();
|
||||
owner()->update(bv, font, true);
|
||||
}
|
||||
return;
|
||||
@ -522,11 +523,7 @@ void InsetText::update(BufferView * bv, LyXFont const & font, bool reinit)
|
||||
in_update = true;
|
||||
if (reinit || need_update == INIT) {
|
||||
need_update |= FULL;
|
||||
#if 0
|
||||
resizeLyXText(bv);
|
||||
#else
|
||||
reinitLyXText();
|
||||
#endif
|
||||
if (owner())
|
||||
owner()->update(bv, font, true);
|
||||
in_update = false;
|
||||
@ -743,6 +740,8 @@ void InsetText::insetUnlock(BufferView * bv)
|
||||
->cursor.par()->getLayout());
|
||||
} else
|
||||
bv->owner()->setLayout(bv->text->cursor.par()->getLayout());
|
||||
// hack for deleteEmptyParMech
|
||||
lt->setCursor(bv, par, 0);
|
||||
updateLocal(bv, code, false);
|
||||
if (clear)
|
||||
lt = 0;
|
||||
|
@ -16,6 +16,9 @@
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
// temporary until verified (08/08/2001 Jug)
|
||||
#define SPECIAL_COLUM_HANDLING 1
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
|
||||
@ -435,17 +438,43 @@ bool LyXTabular::BottomLine(int cell, bool onlycolumn) const
|
||||
|
||||
bool LyXTabular::LeftLine(int cell, bool onlycolumn) const
|
||||
{
|
||||
if (!onlycolumn && IsMultiColumn(cell))
|
||||
if (!onlycolumn && IsMultiColumn(cell)) {
|
||||
#ifdef SPECIAL_COLUM_HANDLING
|
||||
if (cellinfo_of_cell(cell)->align_special.empty())
|
||||
return cellinfo_of_cell(cell)->left_line;
|
||||
return prefixIs(frontStrip(cellinfo_of_cell(cell)->align_special), "|");
|
||||
#else
|
||||
return cellinfo_of_cell(cell)->left_line;
|
||||
#endif
|
||||
}
|
||||
#ifdef SPECIAL_COLUM_HANDLING
|
||||
if (column_info[column_of_cell(cell)].align_special.empty())
|
||||
return column_info[column_of_cell(cell)].left_line;
|
||||
return prefixIs(frontStrip(column_info[column_of_cell(cell)].align_special), "|");
|
||||
#else
|
||||
return column_info[column_of_cell(cell)].left_line;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool LyXTabular::RightLine(int cell, bool onlycolumn) const
|
||||
{
|
||||
if (!onlycolumn && IsMultiColumn(cell))
|
||||
if (!onlycolumn && IsMultiColumn(cell)) {
|
||||
#ifdef SPECIAL_COLUM_HANDLING
|
||||
if (cellinfo_of_cell(cell)->align_special.empty())
|
||||
return cellinfo_of_cell(cell)->right_line;
|
||||
return suffixIs(strip(cellinfo_of_cell(cell)->align_special), "|");
|
||||
#else
|
||||
return cellinfo_of_cell(cell)->right_line;
|
||||
#endif
|
||||
}
|
||||
#ifdef SPECIAL_COLUM_HANDLING
|
||||
if (column_info[column_of_cell(cell)].align_special.empty())
|
||||
return column_info[right_column_of_cell(cell)].right_line;
|
||||
return suffixIs(strip(column_info[column_of_cell(cell)].align_special), "|");
|
||||
#else
|
||||
return column_info[right_column_of_cell(cell)].right_line;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -478,7 +507,11 @@ bool LyXTabular::LeftAlreadyDrawed(int cell) const
|
||||
LyXTabular::CELL_PART_OF_MULTICOLUMN));
|
||||
if (GetAdditionalWidth(cell_info[row][column].cellno))
|
||||
return false;
|
||||
#ifdef SPECIAL_COLUM_HANDLING
|
||||
return column_info[column].right_line;
|
||||
#else
|
||||
return RightLine(cell_info[row][column].cellno, true);
|
||||
#endif
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -527,12 +560,15 @@ int LyXTabular::GetAdditionalWidth(int cell) const
|
||||
// internally already set in SetWidthOfCell
|
||||
// used to get it back in text.C
|
||||
int const col = right_column_of_cell(cell);
|
||||
if (col < columns_ - 1 && column_info[col].right_line &&
|
||||
column_info[col+1].left_line)
|
||||
int const row = row_of_cell(cell);
|
||||
if (col < columns_ - 1 && RightLine(cell, true) &&
|
||||
LeftLine(cell_info[row][col+1].cellno, true)) // column_info[col+1].left_line)
|
||||
{
|
||||
return WIDTH_OF_LINE;
|
||||
else
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// returns the maximum over all rows
|
||||
@ -608,17 +644,28 @@ bool LyXTabular::SetWidthOfCell(int cell, int new_width)
|
||||
int const column1 = column_of_cell(cell);
|
||||
bool tmp = false;
|
||||
int width = 0;
|
||||
int add_width = 0;
|
||||
|
||||
if (GetWidthOfCell(cell) == (new_width+2*WIDTH_OF_LINE))
|
||||
#ifdef SPECIAL_COLUM_HANDLING
|
||||
if (RightLine(cell_info[row][column1].cellno, true) &&
|
||||
(column1 < columns_-1) &&
|
||||
LeftLine(cell_info[row][column1+1].cellno, true))
|
||||
#else
|
||||
if (column_info[column1].right_line && (column1 < columns_-1) &&
|
||||
column_info[column1+1].left_line) // additional width
|
||||
#endif
|
||||
{
|
||||
// additional width
|
||||
add_width = WIDTH_OF_LINE;
|
||||
}
|
||||
if (GetWidthOfCell(cell) == (new_width+2*WIDTH_OF_LINE+add_width)) {
|
||||
return false;
|
||||
}
|
||||
if (IsMultiColumn(cell, true)) {
|
||||
tmp = SetWidthOfMulticolCell(cell, new_width);
|
||||
} else {
|
||||
width = (new_width + 2*WIDTH_OF_LINE);
|
||||
width = (new_width + 2*WIDTH_OF_LINE + add_width);
|
||||
cell_info[row][column1].width_of_cell = width;
|
||||
if (column_info[column1].right_line && (column1 < columns_-1) &&
|
||||
column_info[column1+1].left_line) // additional width
|
||||
cell_info[row][column1].width_of_cell += WIDTH_OF_LINE;
|
||||
tmp = calculate_width_of_column_NMC(column1);
|
||||
}
|
||||
if (tmp) {
|
||||
@ -2100,11 +2147,12 @@ int LyXTabular::Latex(Buffer const * buf,
|
||||
else
|
||||
os << "\\begin{tabular}{";
|
||||
for (int i = 0; i < columns_; ++i) {
|
||||
if (column_info[i].left_line)
|
||||
os << '|';
|
||||
if (!column_info[i].align_special.empty()) {
|
||||
os << column_info[i].align_special;
|
||||
} else if (!column_info[i].p_width.empty()) {
|
||||
} else {
|
||||
if (column_info[i].left_line)
|
||||
os << '|';
|
||||
if (!column_info[i].p_width.empty()) {
|
||||
switch (column_info[i].valignment) {
|
||||
case LYX_VALIGN_TOP:
|
||||
os << "p";
|
||||
@ -2135,6 +2183,7 @@ int LyXTabular::Latex(Buffer const * buf,
|
||||
if (column_info[i].right_line)
|
||||
os << '|';
|
||||
}
|
||||
}
|
||||
os << "}\n";
|
||||
++ret;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user