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) ==
(cursor.par()->getInset(cursor.pos() - 1) ==
theLockingInset()->getLockingInset()))
text->setCursor(this, cursor,
- cursor.par(), cursor.pos() - 1);
+ cursor.par(), cursor.pos() - 1);
LyXScreen::Cursor_Shape shape = LyXScreen::BAR_SHAPE;
LyXText * txt = getLyXText();
if (theLockingInset()->getLockingInset()->lyxCode() ==
+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!
+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!
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;
w = 10; // minimum I require!!!
} else {
w -= top_x;
+ if (owner()) {
+ w += owner()->x();
+ }
}
} else if (w < 10) {
w = 10;
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;
}
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();
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);
}
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,
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;
void InsetTabular::update(BufferView * bv, LyXFont const & font, bool reinit)
{
if (in_update) {
- if (reinit && owner()) {
- owner()->update(bv, font, true);
+ if (reinit) {
+ resetPos(bv);
+ if (owner())
+ owner()->update(bv, font, true);
}
return;
}
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;
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);
bool InsetTabular::calculate_dimensions_of_cells(BufferView * bv,
- LyXFont const & font,
- bool reinit) const
+ LyXFont const & font,
+ bool reinit) const
{
int cell = -1;
int maxAsc = 0;
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;
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));
// 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);
}
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) {
void InsetTabular::tabularFeatures(BufferView * bv,
- LyXTabular::Feature feature,
- string const & value)
+ LyXTabular::Feature feature,
+ string const & value)
{
int sel_col_start;
int sel_col_end;
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
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;
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;
+}
///
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; }
///
{
if (in_update) {
if (reinit && owner()) {
+ reinitLyXText();
owner()->update(bv, font, true);
}
return;
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;
->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;
#pragma implementation
#endif
+// temporary until verified (08/08/2001 Jug)
+#define SPECIAL_COLUM_HANDLING 1
+
#include <algorithm>
#include <cstdlib>
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
}
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;
}
// 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;
+ }
}
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) {
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()) {
- switch (column_info[i].valignment) {
- case LYX_VALIGN_TOP:
- os << "p";
- break;
- case LYX_VALIGN_CENTER:
- os << "m";
- break;
- case LYX_VALIGN_BOTTOM:
- os << "b";
- break;
+ } 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";
+ break;
+ case LYX_VALIGN_CENTER:
+ os << "m";
+ break;
+ case LYX_VALIGN_BOTTOM:
+ os << "b";
+ break;
}
- os << "{"
- << column_info[i].p_width
- << '}';
- } else {
- switch (column_info[i].alignment) {
- case LYX_ALIGN_LEFT:
- os << 'l';
- break;
- case LYX_ALIGN_RIGHT:
+ os << "{"
+ << column_info[i].p_width
+ << '}';
+ } else {
+ switch (column_info[i].alignment) {
+ case LYX_ALIGN_LEFT:
+ os << 'l';
+ break;
+ case LYX_ALIGN_RIGHT:
os << 'r';
break;
- default:
- os << 'c';
- break;
+ default:
+ os << 'c';
+ break;
+ }
}
+ if (column_info[i].right_line)
+ os << '|';
}
- if (column_info[i].right_line)
- os << '|';
}
os << "}\n";
++ret;
void LyXText::setCursor(BufferView * bview, Paragraph * par,
- Paragraph::size_type pos,
- bool setfont, bool boundary) const
+ Paragraph::size_type pos,
+ bool setfont, bool boundary) const
{
LyXCursor old_cursor = cursor;
setCursorIntern(bview, par, pos, setfont, boundary);