More fixes.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3143 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Vigna 2001-12-04 16:10:19 +00:00
parent ef9efa6c0d
commit 9d2abd4505
12 changed files with 138 additions and 56 deletions

View File

@ -1,3 +1,8 @@
2001-12-04 Juergen Vigna <jug@sad.it>
* undo_funcs.C (textHandleUndo): added a call to inset->update() so
that we force an update of the inset and it's owners if neccessary.
2001-12-03 Juergen Vigna <jug@sad.it>
* text.C (rowLast): simplified code

View File

@ -1,3 +1,15 @@
2001-12-04 Juergen Vigna <jug@sad.it>
* insetert.C (edit): handle Inlined status.
* insettext.C (insertInset): trying John's fix for the trailing cursor
* insetert.C (insetButtonPress): added to handle inlined status
(insetMotionNotify): ditto.
* insettext.C (clearInset): changed Painter & in BufferView * param,
to be able to call ascent,descent methods.
2001-12-03 Juergen Vigna <jug@sad.it>
* insettext.C (updateInsetInInset): use lt variable to forbid

View File

@ -257,8 +257,14 @@ void InsetERT::edit(BufferView * bv, int x, int y, unsigned int button)
{
if (button == 3)
return;
InsetCollapsable::edit(bv, x, y, button);
if (status_ == Inlined) {
if (!bv->lockInset(this))
return;
inset.edit(bv, x, y, button);
} else {
InsetCollapsable::edit(bv, x, y, button);
}
updateStatus(0);
set_latex_font(bv);
}
@ -280,6 +286,19 @@ void InsetERT::edit(BufferView * bv, bool front)
}
void InsetERT::insetButtonPress(BufferView * bv,
int x, int y, int button)
{
if (status_ == Inlined) {
inset.insetButtonPress(bv, x, y, button);
} else {
InsetCollapsable::insetButtonPress(bv, x, y, button);
}
}
void InsetERT::insetButtonRelease(BufferView * bv, int x, int y, int button)
{
if (button == 3) {
@ -306,6 +325,17 @@ void InsetERT::insetButtonRelease(BufferView * bv, int x, int y, int button)
}
void InsetERT::insetMotionNotify(BufferView * bv,
int x, int y, int state)
{
if (status_ == Inlined) {
inset.insetMotionNotify(bv, x, y, state);
} else {
InsetCollapsable::insetMotionNotify(bv, x, y, state);
}
}
int InsetERT::latex(Buffer const *, std::ostream & os, bool /*fragile*/,
bool /*free_spc*/) const
{

View File

@ -71,8 +71,12 @@ public:
///
SigC::Signal0<void> hideDialog;
///
void insetButtonPress(BufferView *, int x, int y, int button);
///
void insetButtonRelease(BufferView * bv, int x, int y, int button);
///
void insetMotionNotify(BufferView *, int x, int y, int state);
///
int latex(Buffer const *, std::ostream &, bool fragile,
bool free_spc) const;
///

View File

@ -587,6 +587,10 @@ void InsetTabular::insetUnlock(BufferView * bv)
void InsetTabular::updateLocal(BufferView * bv, UpdateCodes what,
bool mark_dirty) const
{
if (what == INIT) {
LyXFont font;
calculate_dimensions_of_cells(bv, font, true);
}
if (need_update < what) // only set this if it has greater update
need_update = what;
if ((what == INIT) && hasSelection())
@ -1244,6 +1248,8 @@ bool InsetTabular::calculate_dimensions_of_cells(BufferView * bv,
changed = tabular->SetAscentOfRow(i, maxAsc + ADD_TO_HEIGHT) || changed;
changed = tabular->SetDescentOfRow(i, maxDesc + ADD_TO_HEIGHT) || changed;
}
if (changed)
tabular->reinit();
return changed;
}

View File

@ -376,7 +376,7 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
// repaint the background if needed
if (cleared && backgroundColor() != LColor::background) {
top_x = int(x);
clearInset(pain, baseline, cleared);
clearInset(bv, baseline, cleared);
top_x = old_x;
}
@ -400,7 +400,7 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
if (!cleared && (top_x == int(x)) &&
((need_update&(INIT|FULL)) || (top_baseline!=baseline) ||
(last_drawn_width!=insetWidth))) {
clearInset(pain, baseline, cleared);
clearInset(bv, baseline, cleared);
}
top_x = int(x);
@ -419,9 +419,9 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
last_width = width(bv, f);
last_height = ascent(bv, f) + descent(bv, f);
if (cleared || (last_drawn_width != insetWidth)) {
if (last_drawn_width != insetWidth) {
if (!cleared)
clearInset(pain, baseline, cleared);
clearInset(bv, baseline, cleared);
need_update |= FULL;
last_drawn_width = insetWidth;
}
@ -1004,14 +1004,22 @@ void InsetText::insetMotionNotify(BufferView * bv, int x, int y, int state)
y - inset_y,state);
return;
}
LyXText * t = getLyXText(bv);
bool clear = false;
if (!lt) {
lt = getLyXText(bv);
clear = true;
}
hideInsetCursor(bv);
t->setCursorFromCoordinates(bv, x - drawTextXOffset, y + insetAscent);
t->setSelection(bv);
if (t->toggle_cursor.par() != t->toggle_end_cursor.par() ||
t->toggle_cursor.pos() != t->toggle_end_cursor.pos())
lt->setCursorFromCoordinates(bv, x - drawTextXOffset, y + insetAscent);
lt->setSelection(bv);
if (lt->toggle_cursor.par() != lt->toggle_end_cursor.par() ||
lt->toggle_cursor.pos() != lt->toggle_end_cursor.pos())
{
updateLocal(bv, SELECTION, false);
}
showInsetCursor(bv);
if (clear)
lt = 0;
}
@ -1782,7 +1790,7 @@ bool InsetText::insertInset(BufferView * bv, Inset * inset)
#endif
bv->fitCursor();
updateLocal(bv, CURSOR_PAR|CURSOR, true);
showInsetCursor(bv);
// showInsetCursor(bv);
if (clear)
lt = 0;
return true;
@ -2282,10 +2290,12 @@ void InsetText::clearSelection(BufferView * bv)
}
void InsetText::clearInset(Painter & pain, int baseline, bool & cleared) const
void InsetText::clearInset(BufferView * bv, int baseline, bool & cleared) const
{
LyXFont dummy;
Painter & pain = bv->painter();
int w = insetWidth;
int h = insetAscent + insetDescent;
int h = ascent(bv, dummy) + descent(bv, dummy);
int ty = baseline - insetAscent;
if (ty < 0) {
@ -2318,7 +2328,6 @@ Paragraph * InsetText::getParFromID(int id) const
#else
Paragraph * tmp = par;
while (tmp) {
int tmp_id = tmp->id();
if (tmp->id() == id) {
return tmp;
}
@ -2365,6 +2374,14 @@ Paragraph * InsetText::paragraph() const
void InsetText::paragraph(Paragraph * p)
{
// first we have to delete the old contents otherwise we'll have a
// memory leak!
the_locking_inset = 0;
while (par) {
Paragraph * tmp = par->next();
delete par;
par = tmp;
}
par = p;
// set ourself as owner for all the paragraphs inserted!
Paragraph * np = par;

View File

@ -320,7 +320,7 @@ private:
///
void clearFrame(Painter &, bool cleared) const;
///
void clearInset(Painter &, int baseline, bool & cleared) const;
void clearInset(BufferView *, int baseline, bool & cleared) const;
///
void saveLyXTextState(LyXText *) const;
void restoreLyXTextState(BufferView *, LyXText *) const;

View File

@ -341,12 +341,20 @@ void LyXTabular::DeleteColumn(int column)
}
void LyXTabular::Reinit()
{
for (int i = 0; i < rows_; ++i) {
for (int j = 0; j < columns_; ++j) {
cell_info[i][j].width_of_cell = 0;
cell_info[i][j].inset.setOwner(owner_);
void LyXTabular::reinit()
{
Reinit(false);
}
void LyXTabular::Reinit(bool reset_widths)
{
if (reset_widths) {
for (int i = 0; i < rows_; ++i) {
for (int j = 0; j < columns_; ++j) {
cell_info[i][j].width_of_cell = 0;
cell_info[i][j].inset.setOwner(owner_);
}
}
}

View File

@ -394,6 +394,9 @@ public:
///
std::vector<string> const getLabelList() const;
///
/// recalculate the widths/heights only!
void reinit();
///
mutable int cur_cell;
private:
///
@ -518,7 +521,7 @@ private:
///
void Init(int columns_arg, int rows_arg, LyXTabular const * lt = 0);
///
void Reinit();
void Reinit(bool reset_widths = true);
///
void set_row_column_number_info(bool oldformat = false);
/// Returns true if a complete update is necessary, otherwise false

View File

@ -181,7 +181,7 @@ unsigned char LyXText::transformChar(unsigned char c, Paragraph * par,
// Lgb
int LyXText::singleWidth(BufferView * bview, Paragraph * par,
pos_type pos) const
pos_type pos) const
{
char const c = par->getChar(pos);
return singleWidth(bview, par, pos, c);
@ -215,7 +215,10 @@ int LyXText::singleWidth(BufferView * bview, Paragraph * par,
} else if (c == Paragraph::META_INSET) {
Inset * tmpinset = par->getInset(pos);
if (tmpinset) {
#if 0 // seems not to be needed, but ...
#if 1
// this IS needed otherwise on initialitation we don't get the fill
// of the row right (ONLY on initialization if we read a file!)
// should be changed! (Jug 20011204)
tmpinset->update(bview, font);
#endif
return tmpinset->width(bview, font);
@ -1039,13 +1042,6 @@ int LyXText::fill(BufferView * bview, Row * row, int paper_width) const
}
int const fill = paper_width - w - rightMargin(bview->buffer(), row);
#ifdef WITH_WARNINGS
#warning Please fix me (Jug!)
#endif
#if 0
if (fill < 0)
return 0;
#endif
return fill;
}
@ -1515,35 +1511,34 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row_ptr) const
* start at the implicit given position */
void LyXText::appendParagraph(BufferView * bview, Row * row) const
{
bool not_ready = true;
bool not_ready = true;
// The last character position of a paragraph is an invariant so we can
// safely get it here. (Asger)
pos_type const lastposition = row->par()->size();
do {
// Get the next breakpoint
pos_type z = nextBreakPoint(bview, row, workWidth(bview));
// The last character position of a paragraph is an invariant so we can
// safely get it here. (Asger)
pos_type const lastposition = row->par()->size();
do {
// Get the next breakpoint
pos_type z = nextBreakPoint(bview, row, workWidth(bview));
Row * tmprow = row;
Row * tmprow = row;
// Insert the new row
if (z < lastposition) {
++z;
insertRow(row, row->par(), z);
row = row->next();
// Insert the new row
if (z < lastposition) {
++z;
insertRow(row, row->par(), z);
row = row->next();
row->height(0);
} else
not_ready = false;
row->height(0);
} else
not_ready = false;
// Set the dimensions of the row
#ifdef WITH_WARNINGS
#warning Something is rotten here! (Jug)
#endif
tmprow->fill(fill(bview, tmprow, workWidth(bview)));
setHeightOfRow(bview, tmprow);
// Set the dimensions of the row
// fixed fill setting now by calling inset->update() in
// SingleWidth when needed!
tmprow->fill(fill(bview, tmprow, workWidth(bview)));
setHeightOfRow(bview, tmprow);
} while (not_ready);
} while (not_ready);
}

View File

@ -1054,7 +1054,7 @@ void LyXText::clearSelection() const
{
selection.set(false);
selection.mark(false);
selection.end = selection.start = selection.cursor = cursor;
last_sel_cursor = selection.end = selection.start = selection.cursor = cursor;
}

View File

@ -168,6 +168,8 @@ bool textHandleUndo(BufferView * bv, Undo * undo)
it->getLyXText(bv)->setCursorIntern(bv, tmppar, undo->cursor_pos);
it->getLyXText(bv)->updateCounters(bv, it->getLyXText(bv)->cursor.row());
}
LyXFont font;
it->update(bv, font, false);
#ifdef THIS_DOES_NOT_WORK
// we need this anyway as also if the undo was inside an inset
// we have to redo the paragraph breaking