Small fixes noticed by Jean-Marc.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1210 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Vigna 2000-11-10 16:04:51 +00:00
parent 9c798989d9
commit dacb5be646
6 changed files with 71 additions and 28 deletions

View File

@ -1,3 +1,21 @@
2000-11-10 Juergen Vigna <jug@sad.it>
* src/insets/insettext.C (resizeLyXText): check !cache[bv]
(deleteLyXText): ditto
* src/insets/insettabular.C (InsetButtonPress): don't clear the
selection on mouse-button-3.
* src/insets/insettabular.h: new function clearSelection(), use this
functions inside insettabular.C.
* src/insets/insettabular.C (TabularFeatures): clear the selection
on remove_row/column.
* src/insets/inset.C (scroll): fixed some scroll stuff.
* src/insets/insettabular.C (draw): fixed another minor draw problem.
2000-11-10 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* lib/CREDITS: add Yves Bastide

View File

@ -167,6 +167,10 @@ void UpdatableInset::scroll(BufferView * bv, float s) const
{
LyXFont font;
if (!s) {
scx = 0;
return;
}
if (((top_x - scx) > 0) &&
(top_x - scx + width(bv, font)) < bv->workWidth())
return;
@ -189,7 +193,7 @@ void UpdatableInset::scroll(BufferView * bv, float s) const
void UpdatableInset::scroll(BufferView * bv, int offset) const
{
if (offset > 0) {
if (!scx && top_x > 0)
if (!scx && top_x >= 20)
return;
if ((top_x + offset) > 20)
scx += offset - (top_x - scx + offset - 20);

View File

@ -129,9 +129,9 @@ InsetTabular::InsetTabular(Buffer const & buf, int rows, int columns)
locked = no_selection = cursor_visible = false;
cursor.x_fix(-1);
oldcell = -1;
actcell = 0;
actrow = actcell = 0;
cursor.pos(0);
sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0;
clearSelection();
need_update = INIT;
}
@ -144,7 +144,7 @@ InsetTabular::InsetTabular(InsetTabular const & tab, Buffer const & buf)
locked = no_selection = cursor_visible = false;
cursor.x_fix(-1);
oldcell = -1;
actcell = 0;
actrow = actcell = 0;
cursor.pos(0);
sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0;
need_update = INIT;
@ -292,6 +292,7 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
}
i = tabular->row_of_cell(actcell);
if (the_locking_inset == tabular->GetCellInset(cell)) {
#if 0
LyXText::text_status st = bv->text->status;
do {
cx = nx + tabular->GetBeginningOfTextInCell(cell);
@ -310,12 +311,38 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
baseline - tabular->GetAscentOfRow(i) + 1,
tabular->GetWidthOfColumn(cell) -
tabular->GetBeginningOfTextInCell(cell) -
the_locking_inset->width(bv,font) - 1,
the_locking_inset->width(bv,font) -
tabular->GetAdditionalWidth(cell) - 1,
tabular->GetAscentOfRow(i) +
tabular->GetDescentOfRow(i) - 1);
}
tabular->GetCellInset(cell)->draw(bv,font,baseline, cx, false);
} while(bv->text->status == LyXText::CHANGED_IN_DRAW);
#else
cx = nx + tabular->GetBeginningOfTextInCell(cell);
if (need_update == CELL) {
// clear before the inset
pain.fillRectangle(
nx + 1,
baseline - tabular->GetAscentOfRow(i) + 1,
int(cx - nx - 1),
tabular->GetAscentOfRow(i) +
tabular->GetDescentOfRow(i) - 1);
// clear behind the inset
pain.fillRectangle(
int(cx + the_locking_inset->width(bv,font) + 1),
baseline - tabular->GetAscentOfRow(i) + 1,
tabular->GetWidthOfColumn(cell) -
tabular->GetBeginningOfTextInCell(cell) -
the_locking_inset->width(bv,font) -
tabular->GetAdditionalWidth(cell) - 1,
tabular->GetAscentOfRow(i) +
tabular->GetDescentOfRow(i) - 1);
}
tabular->GetCellInset(cell)->draw(bv,font,baseline, cx, false);
if (bv->text->status == LyXText::CHANGED_IN_DRAW)
return;
#endif
}
}
x -= ADD_TO_TABULAR_WIDTH;
@ -592,8 +619,8 @@ bool InsetTabular::InsertInset(BufferView * bv, Inset * inset)
void InsetTabular::InsetButtonPress(BufferView * bv, int x, int y, int button)
{
if (hasSelection()) {
sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0;
if (hasSelection() && (button != 3)) {
clearSelection();
UpdateLocal(bv, SELECTION, false);
}
no_selection = false;
@ -1117,7 +1144,10 @@ void InsetTabular::resetPos(BufferView * bv) const
}
}
static int const offset = ADD_TO_TABULAR_WIDTH + 2;
cursor.x(getCellXPos(actcell) + offset);
int new_x = getCellXPos(actcell);
new_x += offset;
cursor.x(new_x);
// cursor.x(getCellXPos(actcell) + offset);
if (((cursor.x() - offset) > 20) &&
((cursor.x()-offset+tabular->GetWidthOfColumn(actcell)) >
(bv->workWidth()-20)))
@ -1387,6 +1417,7 @@ void InsetTabular::TabularFeatures(BufferView * bv,
if ((row+1) > tabular->rows())
--row;
actcell = tabular->GetCellNumber(row, column);
clearSelection();
UpdateLocal(bv, INIT, true);
break;
case LyXTabular::DELETE_COLUMN:
@ -1394,6 +1425,7 @@ void InsetTabular::TabularFeatures(BufferView * bv,
if ((column+1) > tabular->columns())
--column;
actcell = tabular->GetCellNumber(row, column);
clearSelection();
UpdateLocal(bv, INIT, true);
break;
case LyXTabular::M_TOGGLE_LINE_TOP:

View File

@ -221,6 +221,10 @@ private:
bool hasSelection() const { return ((sel_pos_start != sel_pos_end) ||
(sel_cell_start != sel_cell_end));}
///
void clearSelection() const {
sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0;
}
///
bool ActivateCellInset(BufferView *, int x = 0, int y = 0, int button = 0,
bool behind = false);
///

View File

@ -405,8 +405,6 @@ void InsetText::update(BufferView * bv, LyXFont const & font, bool reinit)
if (need_update == INIT) {
resizeLyXText(bv);
need_update = FULL;
// if (!owner() && bv->text)
// bv->text->UpdateInset(bv, this);
}
int oldw = insetWidth;
#if 1
@ -424,20 +422,7 @@ void InsetText::update(BufferView * bv, LyXFont const & font, bool reinit)
// textWidth(bv->painter()),static_cast<int>(TEXT(bv)->width));
resizeLyXText(bv);
need_update = FULL;
#if 0
if (owner()) {
owner()->update(bv, font, reinit);
return;
} else {
update(bv, font, reinit);
}
#else
#if 1
update(bv, font, reinit);
#else
UpdateLocal(bv, INIT, false);
#endif
#endif
return;
}
if ((need_update==CURSOR_PAR) && (TEXT(bv)->status==LyXText::UNCHANGED) &&
@ -1510,7 +1495,7 @@ LyXText * InsetText::getLyXText(BufferView * bv) const
void InsetText::deleteLyXText(BufferView * bv, bool recursive) const
{
if (cache.find(bv) == cache.end())
if ((cache.find(bv) == cache.end()) || !cache[bv])
return;
delete cache[bv];
cache.erase(bv);
@ -1528,7 +1513,7 @@ void InsetText::resizeLyXText(BufferView * bv) const
{
if (!par->next && !par->size()) // resize not neccessary!
return;
if (cache.find(bv) == cache.end())
if ((cache.find(bv) == cache.end()) || !cache[bv])
return;
LyXParagraph * lpar = 0;

View File

@ -3501,9 +3501,9 @@ Undo * LyXText::CreateUndo(Buffer * buf, Undo::undo_kind kind,
end = end->next;
}
if (start && end
&& start != end->next
&& (before != behind || (!before && !behind))) {
if (start && end && (start != end->next) &&
((before != behind) || (!before && !behind)))
{
tmppar = start;
tmppar2 = tmppar->Clone();
tmppar2->id(tmppar->id());