From b744c6ed9f4dab51e47e4a9bb0331f1740aad335 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Vigna?= Date: Fri, 23 Jun 2000 15:02:46 +0000 Subject: [PATCH] Lot's of updates for new update handling of text-insets git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@831 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 14 +++ src/buffer.C | 14 +++ src/buffer.h | 6 +- src/insets/figinset.C | 2 +- src/insets/figinset.h | 3 +- src/insets/insetbutton.C | 2 +- src/insets/insetbutton.h | 2 +- src/insets/insetcollapsable.C | 9 +- src/insets/insetcollapsable.h | 2 +- src/insets/inseterror.C | 2 +- src/insets/inseterror.h | 2 +- src/insets/insetgraphics.C | 2 +- src/insets/insetgraphics.h | 3 +- src/insets/insetinfo.C | 2 +- src/insets/insetinfo.h | 2 +- src/insets/insetlatexaccent.C | 2 +- src/insets/insetlatexaccent.h | 2 +- src/insets/insetquotes.C | 2 +- src/insets/insetquotes.h | 2 +- src/insets/insetspecialchar.C | 2 +- src/insets/insetspecialchar.h | 2 +- src/insets/insettabular.C | 196 ++++++++++++++++++---------------- src/insets/insettabular.h | 17 ++- src/insets/insettext.C | 56 +++++++--- src/insets/insettext.h | 5 +- src/insets/lyxinset.h | 2 +- src/lyxfunc.C | 2 +- src/lyxparagraph.h | 5 +- src/lyxtext.h | 2 +- src/mathed/formula.C | 2 +- src/mathed/formula.h | 2 +- src/mathed/formulamacro.C | 4 +- src/mathed/formulamacro.h | 2 +- src/paragraph.C | 28 +++++ src/tabular.C | 69 +----------- src/text.C | 33 +++--- src/text2.C | 5 +- 37 files changed, 268 insertions(+), 241 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9000aedbc9..27cdc311f0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2000-06-23 Juergen Vigna + + * src/lyxtext.h: added a 'cleared' flag to draw() function. + + * src/buffer.C (resize): delete the LyXText of textinsets. + + * src/paragraph.C (SetInsetOwner): set the owner in the insets too. + + * src/insets/lyxinset.h: added another parameter 'cleared' to + the draw() function. + + * src/lyxfunc.C (processKeyEvent): move cursor to the right of the + unlocking inset in inset. + 2000-06-22 Juergen Vigna * src/lyxscreen.h: added some y_offset/x_offset parameters for drawings diff --git a/src/buffer.C b/src/buffer.C index cb7233f904..a64627987a 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -3801,6 +3801,20 @@ bool Buffer::Dispatch(int action, string const & argument) } +void Buffer::resize() +{ + /// first resize the BufferViews! + if (users) { + users->resize(); + } + /// then remove all LyXText in text-insets + LyXParagraph * par = paragraph; + for(;par;par = par->next) { + par->deleteInsetsLyXText(users); + } +} + + void Buffer::ChangeLanguage(Language const * from, Language const * to) { diff --git a/src/buffer.h b/src/buffer.h index 6a3117959f..10388ce064 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -88,11 +88,7 @@ public: bool Dispatch(int, auto_mem_buffer &); /// should be changed to work for a list. - void resize() { - if (users) { - users->resize(); - } - } + void resize(); /// Update window titles of all users void updateTitles() const; diff --git a/src/insets/figinset.C b/src/insets/figinset.C index 99e447c6c1..e546f7edbb 100644 --- a/src/insets/figinset.C +++ b/src/insets/figinset.C @@ -1035,7 +1035,7 @@ int InsetFig::width(Painter &, LyXFont const &) const void InsetFig::draw(BufferView * bv, LyXFont const & f, - int baseline, float & x) const + int baseline, float & x, bool) const { LyXFont font(f); Painter & pain = bv->painter(); diff --git a/src/insets/figinset.h b/src/insets/figinset.h index cb53c9218c..28830c735e 100644 --- a/src/insets/figinset.h +++ b/src/insets/figinset.h @@ -30,8 +30,7 @@ public: /// int width(Painter &, LyXFont const & font) const; /// - void draw(BufferView *, LyXFont const & font, - int baseline, float & x) const; + void draw(BufferView *, LyXFont const &, int, float &, bool) const; /// void Write(Buffer const *, std::ostream &) const; /// diff --git a/src/insets/insetbutton.C b/src/insets/insetbutton.C index 327ab0b656..368604e5f0 100644 --- a/src/insets/insetbutton.C +++ b/src/insets/insetbutton.C @@ -88,7 +88,7 @@ int InsetButton::width(Painter & pain, LyXFont const &) const void InsetButton::draw(BufferView * bv, LyXFont const &, - int baseline, float & x) const + int baseline, float & x, bool) const { Painter & pain = bv->painter(); // Draw it as a box with the LaTeX text diff --git a/src/insets/insetbutton.h b/src/insets/insetbutton.h index b88a83729c..056c3fe98d 100644 --- a/src/insets/insetbutton.h +++ b/src/insets/insetbutton.h @@ -33,7 +33,7 @@ public: /// int width(Painter &, LyXFont const &) const; /// - void draw(BufferView *, LyXFont const &, int baseline, float & x) const; + void draw(BufferView *, LyXFont const &, int, float &, bool) const; protected: /// This should provide the text for the button diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 03537313d3..24457fba6d 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -136,7 +136,7 @@ void InsetCollapsable::draw_collapsed(Painter & pain, LyXFont const & font, void InsetCollapsable::draw(BufferView * bv, LyXFont const & f, - int baseline, float & x) const + int baseline, float & x, bool cleared) const { Painter & pain = bv->painter(); @@ -155,12 +155,11 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f, int w = InsetText::width(pain, f) + 2 * TEXT_TO_INSET_OFFSET; int h = ascent(pain,f) + descent(pain, f); - - pain.rectangle(int(x), baseline - ascent(pain, f), w, h, framecolor); - + int save_x = static_cast(x); x += TEXT_TO_INSET_OFFSET; drawTextXOffset = int(x) - top_x; - InsetText::draw(bv, f, baseline, x); + InsetText::draw(bv, f, baseline, x, cleared); + pain.rectangle(save_x, baseline - ascent(pain, f), w, h, framecolor); } diff --git a/src/insets/insetcollapsable.h b/src/insets/insetcollapsable.h index 5107c44837..73bbc42d4e 100644 --- a/src/insets/insetcollapsable.h +++ b/src/insets/insetcollapsable.h @@ -51,7 +51,7 @@ public: /// int width(Painter &, LyXFont const & f) const; /// - void draw(BufferView *, const LyXFont &, int , float &) const; + void draw(BufferView *, const LyXFont &, int , float &, bool) const; /// void Edit(BufferView *, int, int, unsigned int); /// diff --git a/src/insets/inseterror.C b/src/insets/inseterror.C index cc7584a287..493a01de20 100644 --- a/src/insets/inseterror.C +++ b/src/insets/inseterror.C @@ -73,7 +73,7 @@ int InsetError::width(Painter &, LyXFont const & font) const void InsetError::draw(BufferView * bv, LyXFont const & font, - int baseline, float & x) const + int baseline, float & x, bool) const { Painter & pain = bv->painter(); LyXFont efont; diff --git a/src/insets/inseterror.h b/src/insets/inseterror.h index 1147e47e74..eadf9fb513 100644 --- a/src/insets/inseterror.h +++ b/src/insets/inseterror.h @@ -42,7 +42,7 @@ public: /// int width(Painter &, LyXFont const & font) const; /// - void draw(BufferView *, LyXFont const & font, int baseline, float & x) const; + void draw(BufferView *, LyXFont const &, int, float &, bool) const; /// void Write(Buffer const *, std::ostream &) const; /// diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 35716df97f..586934dd14 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -135,7 +135,7 @@ int InsetGraphics::width(Painter &, LyXFont const &) const void InsetGraphics::draw(BufferView * bv, LyXFont const & font, - int baseline, float & x) const + int baseline, float & x, bool) const { Painter & pain = bv->painter(); diff --git a/src/insets/insetgraphics.h b/src/insets/insetgraphics.h index 76d2ec824e..e9cc6d563b 100644 --- a/src/insets/insetgraphics.h +++ b/src/insets/insetgraphics.h @@ -35,8 +35,7 @@ public: /// int width(Painter &, LyXFont const &) const; /// - void draw(BufferView *, LyXFont const &, - int baseline, float & x) const; + void draw(BufferView *, LyXFont const &, int, float &, bool) const; /// void Edit(BufferView *, int, int, unsigned int); /// diff --git a/src/insets/insetinfo.C b/src/insets/insetinfo.C index e57b91f042..847f37492c 100644 --- a/src/insets/insetinfo.C +++ b/src/insets/insetinfo.C @@ -76,7 +76,7 @@ int InsetInfo::width(Painter &, LyXFont const & font) const void InsetInfo::draw(BufferView * bv, LyXFont const & f, - int baseline, float & x) const + int baseline, float & x, bool) const { Painter & pain = bv->painter(); LyXFont font(f); diff --git a/src/insets/insetinfo.h b/src/insets/insetinfo.h index ef1cf83e1a..8898a874e4 100644 --- a/src/insets/insetinfo.h +++ b/src/insets/insetinfo.h @@ -44,7 +44,7 @@ public: /// int width(Painter &, LyXFont const &) const; /// - void draw(BufferView *, LyXFont const &, int baseline, float & x) const; + void draw(BufferView *, LyXFont const &, int, float &, bool) const; /// void Write(Buffer const *, std::ostream &) const; /// diff --git a/src/insets/insetlatexaccent.C b/src/insets/insetlatexaccent.C index 89fdbfc710..9b74cd696b 100644 --- a/src/insets/insetlatexaccent.C +++ b/src/insets/insetlatexaccent.C @@ -356,7 +356,7 @@ bool InsetLatexAccent::DisplayISO8859_9(Painter & pain, LyXFont const & font, void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font, - int baseline, float & x) const + int baseline, float & x, bool) const { Painter & pain = bv->painter(); diff --git a/src/insets/insetlatexaccent.h b/src/insets/insetlatexaccent.h index 5e44470376..9a73aa3704 100644 --- a/src/insets/insetlatexaccent.h +++ b/src/insets/insetlatexaccent.h @@ -41,7 +41,7 @@ public: /// int width(Painter &, LyXFont const &) const; /// - void draw(BufferView *, LyXFont const &, int baseline, float & x) const; + void draw(BufferView *, LyXFont const &, int, float &, bool) const; /// int Lbearing(LyXFont const & font) const; /// diff --git a/src/insets/insetquotes.C b/src/insets/insetquotes.C index f2dfa4238e..ab0adde855 100644 --- a/src/insets/insetquotes.C +++ b/src/insets/insetquotes.C @@ -198,7 +198,7 @@ LyXFont InsetQuotes::ConvertFont(LyXFont font) void InsetQuotes::draw(BufferView * bv, LyXFont const & font, - int baseline, float & x) const + int baseline, float & x, bool) const { string text = DispString(); diff --git a/src/insets/insetquotes.h b/src/insets/insetquotes.h index 3c6a6f24b1..cb8b4d9c10 100644 --- a/src/insets/insetquotes.h +++ b/src/insets/insetquotes.h @@ -78,7 +78,7 @@ public: /// int width(Painter &, LyXFont const &) const; /// - void draw(BufferView *, LyXFont const &, int baseline, float & x) const; + void draw(BufferView *, LyXFont const &, int, float &, bool) const; /// LyXFont ConvertFont(LyXFont font); /// diff --git a/src/insets/insetspecialchar.C b/src/insets/insetspecialchar.C index 81431d769f..172e0d4aaa 100644 --- a/src/insets/insetspecialchar.C +++ b/src/insets/insetspecialchar.C @@ -73,7 +73,7 @@ int InsetSpecialChar::width(Painter &, LyXFont const & font) const void InsetSpecialChar::draw(BufferView * bv, LyXFont const & f, - int baseline, float & x) const + int baseline, float & x, bool) const { Painter & pain = bv->painter(); LyXFont font(f); diff --git a/src/insets/insetspecialchar.h b/src/insets/insetspecialchar.h index d02aec0d65..cb696cd97e 100644 --- a/src/insets/insetspecialchar.h +++ b/src/insets/insetspecialchar.h @@ -50,7 +50,7 @@ public: /// int width(Painter &, LyXFont const &) const; /// - void draw(BufferView *, LyXFont const &, int baseline, float & x) const; + void draw(BufferView *, LyXFont const &, int, float &, bool) const; /// void Write(Buffer const *, std::ostream &) const; /// Will not be used when lyxf3 diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 642fe07abf..2acf665178 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -63,7 +63,7 @@ InsetTabular::InsetTabular(Buffer * buf, int rows, int columns) actcell = 0; cursor.pos(0); sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0; - init_inset = true; + need_update = INIT; } @@ -78,7 +78,7 @@ InsetTabular::InsetTabular(InsetTabular const & tab, Buffer * buf) actcell = 0; cursor.pos(0); sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0; - init_inset = true; + need_update = INIT; } @@ -113,7 +113,7 @@ void InsetTabular::Read(Buffer const * buf, LyXLex & lex) delete tabular; tabular = new LyXTabular(buf, this, lex); - init_inset = true; + need_update = INIT; if (old_format) return; @@ -150,7 +150,7 @@ int InsetTabular::width(Painter &, LyXFont const &) const void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline, - float & x) const + float & x, bool cleared) const { Painter & pain = bv->painter(); int i, j, cell=0; @@ -158,8 +158,8 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline, float cx; UpdatableInset::draw(bv,font,baseline,x); - if (init_inset || (top_x != int(x)) || (top_baseline != baseline)) { - init_inset = false; + if ((need_update == INIT)|| (top_x != int(x)) || (top_baseline != baseline)) { + need_update = FULL; top_x = int(x); top_baseline = baseline; resetPos(pain); @@ -172,35 +172,39 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline, return; } } + bool dodraw; x += ADD_TO_TABULAR_WIDTH; - for(i=0;irows();++i) { - nx = int(x); - for(j=0;jcolumns();++j) { - if (tabular->IsPartOfMultiColumn(i,j)) - continue; - cx = nx + tabular->GetBeginningOfTextInCell(cell); - if (hasSelection()) - DrawCellSelection(pain, nx, baseline, i, j, cell); - tabular->GetCellInset(cell)->draw(bv, font, baseline, cx); - DrawCellLines(pain, nx, baseline, i, cell); - nx += tabular->GetWidthOfColumn(cell); - ++cell; + if (cleared || !locked || (need_update == FULL) || (need_update == CELL)) { + for(i=0;irows();++i) { + nx = int(x); + dodraw = ((baseline+tabular->GetDescentOfRow(i)) > 0) && + (baseline-tabular->GetAscentOfRow(i)) < pain.paperHeight(); + for(j=0;jcolumns();++j) { + if (tabular->IsPartOfMultiColumn(i,j)) + continue; + cx = nx + tabular->GetBeginningOfTextInCell(cell); + if (hasSelection()) + DrawCellSelection(pain, nx, baseline, i, j, cell); + if (dodraw && !cleared && locked && the_locking_inset) { + if (the_locking_inset == tabular->GetCellInset(cell)) + tabular->GetCellInset(cell)->draw(bv, font, + baseline, cx, + cleared); + } else if (dodraw) { + tabular->GetCellInset(cell)->draw(bv, font, baseline, cx, + cleared); + DrawCellLines(pain, nx, baseline, i, cell); + } + nx += tabular->GetWidthOfColumn(cell); + ++cell; + } + baseline += tabular->GetDescentOfRow(i) + + tabular->GetAscentOfRow(i+1)+ + tabular->GetAdditionalHeight(cell+1); } - baseline += tabular->GetDescentOfRow(i) + tabular->GetAscentOfRow(i+1) - + tabular->GetAdditionalHeight(cell+1); } x += width(pain, font); -} - - -void InsetTabular::update(BufferView * bv, LyXFont const & font, bool dodraw) -{ - if (the_locking_inset) - the_locking_inset->update(bv, font, dodraw); - if (init_inset) { -// calculate_dimensions_of_cells(bv, font, dodraw); - init_inset = calculate_dimensions_of_cells(bv, font, dodraw) || init_inset; - } + need_update = NONE; } @@ -270,6 +274,26 @@ void InsetTabular::DrawCellSelection(Painter & pain, int x, int baseline, } +void InsetTabular::update(BufferView * bv, LyXFont const & font, bool dodraw) +{ + if (the_locking_inset) + the_locking_inset->update(bv, font, dodraw); + switch(need_update) { + case INIT: + case FULL: + case CELL: + if (calculate_dimensions_of_cells(bv, font, dodraw)) + need_update = INIT; + break; + case SELECTION: + need_update = INIT; + break; + default: + break; + } +} + + char const * InsetTabular::EditMessage() const { return _("Opened Tabular Inset"); @@ -294,7 +318,7 @@ void InsetTabular::Edit(BufferView * bv, int x, int y, unsigned int button) if (InsetHit(bv, x, y)) { ActivateCellInset(bv, x, y, button); } - UpdateLocal(bv, false, false); + UpdateLocal(bv, NONE, false); // bv->getOwner()->getPopups().updateFormTabular(); } @@ -308,20 +332,21 @@ void InsetTabular::InsetUnlock(BufferView * bv) } HideInsetCursor(bv); if (hasSelection()) { - sel_pos_start = sel_pos_end = cursor.pos(); - sel_cell_start = sel_cell_end = actcell; - UpdateLocal(bv, false, false); + sel_pos_start = sel_pos_end = 0; + sel_cell_start = sel_cell_end = 0; + UpdateLocal(bv, FULL, false); } no_selection = false; oldcell = -1; locked = false; } -void InsetTabular::UpdateLocal(BufferView * bv, bool what, bool mark_dirty) +void InsetTabular::UpdateLocal(BufferView * bv, UpdateCodes what, + bool mark_dirty) { - init_inset = what; + need_update = what; bv->updateInset(this, mark_dirty); - if (what) + if (what != NONE) resetPos(bv->painter()); } @@ -366,7 +391,7 @@ bool InsetTabular::UnlockInsetInInset(BufferView * bv, UpdatableInset * inset, the_locking_inset = 0; if (lr) moveRight(bv, false); - UpdateLocal(bv, true, false); + UpdateLocal(bv, CELL, false); return true; } if (the_locking_inset->UnlockInsetInInset(bv, inset, lr)) { @@ -387,7 +412,7 @@ bool InsetTabular::UpdateInsetInInset(BufferView * bv, Inset * inset) return false; if (the_locking_inset != inset) return the_locking_inset->UpdateInsetInInset(bv, inset); - UpdateLocal(bv, false, false); + UpdateLocal(bv, CELL, false); return true; } @@ -451,7 +476,7 @@ 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; - UpdateLocal(bv, false, false); + UpdateLocal(bv, SELECTION, false); } no_selection = false; @@ -499,7 +524,7 @@ void InsetTabular::InsetMotionNotify(BufferView * bv, int x, int y, int button) sel_pos_end = cursor.pos(); sel_cell_end = actcell; if (old != sel_pos_end) - UpdateLocal(bv, false, false); + UpdateLocal(bv, SELECTION, false); #if 0 if (ocell != actcell) bview->getOwner()->getPopups().updateFormTabular(); @@ -544,9 +569,8 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action, if (result == DISPATCHED_NOUPDATE) return result; else if (result == DISPATCHED) { - bool upd = SetCellDimensions(bv->painter(), actcell, actrow); the_locking_inset->ToggleInsetCursor(bv); - UpdateLocal(bv, upd, false); + UpdateLocal(bv, CELL, false); the_locking_inset->ToggleInsetCursor(bv); return result; } else if (result == FINISHED) { @@ -581,14 +605,14 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action, else sel_cell_end = actcell; } - UpdateLocal(bv, false, false); + UpdateLocal(bv, SELECTION, false); break; case LFUN_RIGHT: result = moveRight(bv); sel_pos_start = sel_pos_end = cursor.pos(); sel_cell_start = sel_cell_end = actcell; if (hs) - UpdateLocal(bv, false, false); + UpdateLocal(bv, CURSOR, false); break; case LFUN_LEFTSEL: if (tabular->IsFirstCellInRow(actcell) && cellstart(cursor.pos())) @@ -602,14 +626,14 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action, else sel_cell_end = actcell-1; } - UpdateLocal(bv, false, false); + UpdateLocal(bv, SELECTION, false); break; case LFUN_LEFT: result = moveLeft(bv); sel_pos_start = sel_pos_end = cursor.pos(); sel_cell_start = sel_cell_end = actcell; if (hs) - UpdateLocal(bv, false, false); + UpdateLocal(bv, CURSOR, false); break; case LFUN_DOWNSEL: { @@ -621,7 +645,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action, sel_cell_end = tabular->GetCellBelow(sel_cell_end); else sel_cell_end = tabular->GetLastCellBelow(sel_cell_end); - UpdateLocal(bv, false, false); + UpdateLocal(bv, SELECTION, false); } break; case LFUN_DOWN: @@ -629,7 +653,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action, sel_pos_start = sel_pos_end = cursor.pos(); sel_cell_start = sel_cell_end = actcell; if (hs) - UpdateLocal(bv, false, false); + UpdateLocal(bv, CURSOR, false); break; case LFUN_UPSEL: { @@ -641,7 +665,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action, sel_cell_end = tabular->GetCellAbove(sel_cell_end); else sel_cell_end = tabular->GetLastCellAbove(sel_cell_end); - UpdateLocal(bv, false, false); + UpdateLocal(bv, SELECTION, false); } break; case LFUN_UP: @@ -649,7 +673,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action, sel_pos_start = sel_pos_end = cursor.pos(); sel_cell_start = sel_cell_end = actcell; if (hs) - UpdateLocal(bv, false, false); + UpdateLocal(bv, CURSOR, false); break; case LFUN_BACKSPACE: break; @@ -672,7 +696,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action, sel_pos_start = sel_pos_end = cursor.pos(); sel_cell_start = sel_cell_end = actcell; if (hs) - UpdateLocal(bv, false, false); + UpdateLocal(bv, CURSOR, false); break; case LFUN_LAYOUT_TABLE: { @@ -885,28 +909,6 @@ void InsetTabular::resetPos(Painter & pain) const } -bool InsetTabular::SetCellDimensions(Painter & pain, int cell, int row) -{ - InsetText * inset = tabular->GetCellInset(cell); - LyXFont font(LyXFont::ALL_SANE); - int asc = inset->ascent(pain, font) + ADD_TO_HEIGHT; - int desc = inset->descent(pain, font) + ADD_TO_HEIGHT; - int maxAsc = tabular->GetAscentOfRow(row); - int maxDesc = tabular->GetDescentOfRow(row); - bool ret = tabular->SetWidthOfCell(cell, inset->width(pain, font)); - - if (maxAsc < asc) { - ret = true; - tabular->SetAscentOfRow(row, asc); - } - if (maxDesc < desc) { - ret = true; - tabular->SetDescentOfRow(row, desc); - } - return ret; -} - - UpdatableInset::RESULT InsetTabular::moveRight(BufferView * bv, bool lock) { if (!cellstart(cursor.pos())) { @@ -1066,8 +1068,13 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val) { bool update = (tabular->GetPWidth(actcell) != val); tabular->SetPWidth(actcell,val); - if (update) - UpdateLocal(bv, true, true); + if (update) { + for (int i=0; i < tabular->rows(); ++i) { + tabular->GetCellInset(tabular->GetCellNumber(i, column))-> + deleteLyXText(bv); + } + UpdateLocal(bv, INIT, true); + } } break; case LyXTabular::SET_SPECIAL_COLUMN: @@ -1078,34 +1085,34 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val) // append the row into the tabular UnlockInsetInInset(bv, the_locking_inset); tabular->AppendRow(actcell); - UpdateLocal(bv, true, true); + UpdateLocal(bv, INIT, true); break; case LyXTabular::APPEND_COLUMN: // append the column into the tabular tabular->AppendColumn(actcell); actcell = tabular->GetCellNumber(row, column); - UpdateLocal(bv, true, true); + UpdateLocal(bv, INIT, true); break; case LyXTabular::DELETE_ROW: tabular->DeleteRow(tabular->row_of_cell(actcell)); if ((row+1) > tabular->rows()) --row; actcell = tabular->GetCellNumber(row, column); - UpdateLocal(bv, true, true); + UpdateLocal(bv, INIT, true); break; case LyXTabular::DELETE_COLUMN: tabular->DeleteColumn(tabular->column_of_cell(actcell)); if ((column+1) > tabular->columns()) --column; actcell = tabular->GetCellNumber(row, column); - UpdateLocal(bv, true, true); + UpdateLocal(bv, INIT, true); break; case LyXTabular::TOGGLE_LINE_TOP: lineSet = !tabular->TopLine(actcell); for(i=sel_row_start; i<=sel_row_end; ++i) for(j=sel_col_start; j<=sel_col_end; ++j) tabular->SetTopLine(tabular->GetCellNumber(i,j),lineSet); - UpdateLocal(bv, true, true); + UpdateLocal(bv, INIT, true); break; case LyXTabular::TOGGLE_LINE_BOTTOM: @@ -1113,7 +1120,7 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val) for(i=sel_row_start; i<=sel_row_end; ++i) for(j=sel_col_start; j<=sel_col_end; ++j) tabular->SetBottomLine(tabular->GetCellNumber(i,j),lineSet); - UpdateLocal(bv, true, true); + UpdateLocal(bv, INIT, true); break; case LyXTabular::TOGGLE_LINE_LEFT: @@ -1121,7 +1128,7 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val) for(i=sel_row_start; i<=sel_row_end; ++i) for(j=sel_col_start; j<=sel_col_end; ++j) tabular->SetLeftLine(tabular->GetCellNumber(i,j),lineSet); - UpdateLocal(bv, true, true); + UpdateLocal(bv, INIT, true); break; case LyXTabular::TOGGLE_LINE_RIGHT: @@ -1129,7 +1136,7 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val) for(i=sel_row_start; i<=sel_row_end; ++i) for(j=sel_col_start; j<=sel_col_end; ++j) tabular->SetRightLine(tabular->GetCellNumber(i,j),lineSet); - UpdateLocal(bv, true, true); + UpdateLocal(bv, INIT, true); break; case LyXTabular::ALIGN_LEFT: case LyXTabular::ALIGN_RIGHT: @@ -1137,7 +1144,10 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val) for(i=sel_row_start; i<=sel_row_end; ++i) for(j=sel_col_start; j<=sel_col_end; ++j) tabular->SetAlignment(tabular->GetCellNumber(i,j),setAlign); - UpdateLocal(bv, true, true); + if (hasSelection()) + UpdateLocal(bv, INIT, true); + else + UpdateLocal(bv, CELL, true); break; case LyXTabular::MULTICOLUMN: { @@ -1152,10 +1162,10 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val) // check wether we are completly in a multicol if (tabular->IsMultiColumn(actcell)) { tabular->UnsetMultiColumn(actcell); - UpdateLocal(bv, true, true); + UpdateLocal(bv, INIT, true); } else { tabular->SetMultiColumn(actcell, 1); - UpdateLocal(bv, false, true); + UpdateLocal(bv, CELL, true); } return; } @@ -1176,7 +1186,7 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val) cursor.pos(0); sel_cell_end = sel_cell_start; sel_pos_end = sel_pos_start; - UpdateLocal(bv, true, true); + UpdateLocal(bv, INIT, true); break; } case LyXTabular::SET_ALL_LINES: @@ -1185,15 +1195,15 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val) for(i=sel_row_start; i<=sel_row_end; ++i) for(j=sel_col_start; j<=sel_col_end; ++j) tabular->SetAllLines(tabular->GetCellNumber(i,j), setLines); - UpdateLocal(bv, true, true); + UpdateLocal(bv, INIT, true); break; case LyXTabular::SET_LONGTABULAR: tabular->SetLongTabular(true); - UpdateLocal(bv, true, true); // because this toggles displayed + UpdateLocal(bv, INIT, true); // because this toggles displayed break; case LyXTabular::UNSET_LONGTABULAR: tabular->SetLongTabular(false); - UpdateLocal(bv, true, true); // because this toggles displayed + UpdateLocal(bv, INIT, true); // because this toggles displayed break; case LyXTabular::SET_ROTATE_TABULAR: tabular->SetRotateTabular(true); @@ -1257,7 +1267,7 @@ bool InsetTabular::ActivateCellInset(BufferView * bv, int x, int y, int button, inset->Edit(bv, x - inset_x, y - inset_y, button); if (!the_locking_inset) return false; - UpdateLocal(bv, true, false); + UpdateLocal(bv, CELL, false); return true; } diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index fe59d089ba..9a2a6ee796 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -61,6 +61,15 @@ class Buffer; class InsetTabular : public UpdatableInset { public: + /// + enum UpdateCodes { + NONE = 0, + INIT, + FULL, + CELL, + CURSOR, + SELECTION + }; /// InsetTabular(Buffer *, int rows=1, int columns=1); /// @@ -80,7 +89,7 @@ public: /// int width(Painter &, LyXFont const & f) const; /// - void draw(BufferView *, const LyXFont &, int , float &) const; + void draw(BufferView *, const LyXFont &, int , float &, bool) const; /// void update(BufferView *, LyXFont const &, bool); /// @@ -92,7 +101,7 @@ public: /// void InsetUnlock(BufferView *); /// - void UpdateLocal(BufferView *, bool what, bool mark_dirty); + void UpdateLocal(BufferView *, UpdateCodes, bool mark_dirty); /// bool LockInsetInInset(BufferView *, UpdatableInset *); /// @@ -166,8 +175,6 @@ private: /// void setPos(Painter &, int x, int y) const; /// - bool SetCellDimensions(Painter & pain, int cell, int row); - /// UpdatableInset::RESULT moveRight(BufferView *, bool lock=true); UpdatableInset::RESULT moveLeft(BufferView *, bool lock=true); UpdatableInset::RESULT moveUp(BufferView *); @@ -216,6 +223,6 @@ private: actrow; bool no_selection; mutable bool locked; - mutable bool init_inset; + mutable UpdateCodes need_update; }; #endif diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 6375665bd5..44d5163933 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -205,16 +205,21 @@ int InsetText::width(Painter &, LyXFont const &) const return insetWidth; } +int InsetText::textWidth(Painter & pain) const +{ + return getMaxTextWidth(pain, this) - drawTextXOffset; +} + void InsetText::draw(BufferView * bv, LyXFont const & f, - int baseline, float & x) const + int baseline, float & x, bool cleared) const { Painter & pain = bv->painter(); xpos = x; UpdatableInset::draw(bv, f, baseline, x); - if (locked && ((need_update==FULL) || (top_x!=int(x)) || + if (!cleared && locked && ((need_update==FULL) || (top_x!=int(x)) || (top_baseline!=baseline))) { need_update = NONE; top_x = int(x); @@ -235,11 +240,16 @@ void InsetText::draw(BufferView * bv, LyXFont const & f, inset_x = cx(bv) - top_x + drawTextXOffset; inset_y = cy(bv) + drawTextYOffset; } + if (need_update == CURSOR) { + x += width(pain, f); + need_update = NONE; + return; + } x += TEXT_TO_INSET_OFFSET; // place for border long int y = 0; Row * row = TEXT(bv)->GetRowNearY(y); y += baseline - row->ascent_of_text() + 1; - if (!locked || (need_update == FULL)) { + if (cleared || !locked || (need_update == FULL)) { while (row != 0) { TEXT(bv)->GetVisibleRow(bv, y, x, row, y); y += row->height(); @@ -252,9 +262,15 @@ void InsetText::draw(BufferView * bv, LyXFont const & f, bv->screen()->Update(TEXT(bv), y, x); locked = true; } + TEXT(bv)->refresh_y = 0; + TEXT(bv)->status = LyXText::UNCHANGED; if (drawLockedFrame && locked) { pain.rectangle(top_x, baseline - ascent(pain, f), width(pain, f), ascent(pain,f) + descent(pain, f), frame_color); + } else { + pain.rectangle(top_x, baseline - ascent(pain, f), width(pain, f), + ascent(pain,f) + descent(pain, f), + LColor::background); } x += width(pain, f) - TEXT_TO_INSET_OFFSET; need_update = NONE; @@ -269,16 +285,18 @@ void InsetText::update(BufferView * bv, LyXFont const & font, bool dodraw) deleteLyXText(bv); need_update = FULL; } - if (dodraw) + if (dodraw && (need_update != CURSOR)) need_update = FULL; TEXT(bv)->FullRebreak(bv); long int y_temp = 0; Row * row = TEXT(bv)->GetRowNearY(y_temp); - insetAscent = row->ascent_of_text() + 2; - insetDescent = TEXT(bv)->height - row->ascent_of_text() + 2; - insetWidth = max(getMaxTextWidth(bv->painter(), this), TEXT(bv)->width); + insetAscent = row->ascent_of_text() + TEXT_TO_INSET_OFFSET; + insetDescent = TEXT(bv)->height - row->ascent_of_text() + + TEXT_TO_INSET_OFFSET; + insetWidth = max(textWidth(bv->painter()), TEXT(bv)->width) + + (2 * TEXT_TO_INSET_OFFSET); } @@ -300,6 +318,8 @@ void InsetText::Edit(BufferView * bv, int x, int y, unsigned int button) locked = true; the_locking_inset = 0; inset_pos = inset_x = inset_y = 0; +#warning Fix cursor setting here!!! (Jug) + TEXT(bv)->SetCursor(bv, par, 0); // setPos(bv->painter(), x, y); checkAndActivateInset(bv, x, y, button); // selection_start_cursor = selection_end_cursor = cursor; @@ -397,8 +417,6 @@ void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button) UpdateLocal(bv, FULL, false); } no_selection = false; -// setPos(bv->painter(), x, y); -// cursor.x_fix(-1); TEXT(bv)->SetCursorFromCoordinates(bv, x, y+TEXT(bv)->first); if (the_locking_inset) { UpdatableInset * inset = 0; @@ -575,7 +593,7 @@ InsetText::LocalDispatch(BufferView * bv, result = moveRight(bv); TEXT(bv)->selection = 0; TEXT(bv)->sel_cursor = TEXT(bv)->cursor; - UpdateLocal(bv, CURSOR_PAR, false); + UpdateLocal(bv, CURSOR, false); break; case LFUN_LEFTSEL: bv->text->FinishUndo(); @@ -588,7 +606,7 @@ InsetText::LocalDispatch(BufferView * bv, result= moveLeft(bv); TEXT(bv)->selection = 0; TEXT(bv)->sel_cursor = TEXT(bv)->cursor; - UpdateLocal(bv, CURSOR_PAR, false); + UpdateLocal(bv, CURSOR, false); break; case LFUN_DOWNSEL: bv->text->FinishUndo(); @@ -601,7 +619,7 @@ InsetText::LocalDispatch(BufferView * bv, result = moveDown(bv); TEXT(bv)->selection = 0; TEXT(bv)->sel_cursor = TEXT(bv)->cursor; - UpdateLocal(bv, CURSOR_PAR, false); + UpdateLocal(bv, CURSOR, false); break; case LFUN_UPSEL: bv->text->FinishUndo(); @@ -614,20 +632,20 @@ InsetText::LocalDispatch(BufferView * bv, result = moveUp(bv); TEXT(bv)->selection = 0; TEXT(bv)->sel_cursor = TEXT(bv)->cursor; - UpdateLocal(bv, CURSOR_PAR, false); + UpdateLocal(bv, CURSOR, false); break; case LFUN_HOME: bv->text->FinishUndo(); TEXT(bv)->CursorHome(bv); TEXT(bv)->selection = 0; TEXT(bv)->sel_cursor = TEXT(bv)->cursor; - UpdateLocal(bv, CURSOR_PAR, false); + UpdateLocal(bv, CURSOR, false); break; case LFUN_END: TEXT(bv)->CursorEnd(bv); TEXT(bv)->selection = 0; TEXT(bv)->sel_cursor = TEXT(bv)->cursor; - UpdateLocal(bv, CURSOR_PAR, false); + UpdateLocal(bv, CURSOR, false); break; case LFUN_BACKSPACE: bv->text->SetUndo(bv->buffer(), Undo::DELETE, @@ -913,8 +931,12 @@ void InsetText::SetFont(BufferView * bv, LyXFont const & font, bool toggleall) void InsetText::UpdateLocal(BufferView * bv, UpdateCodes what, bool mark_dirty) { - need_update = what; - bv->updateInset(this, mark_dirty); + if (TEXT(bv)->status == LyXText::NEED_MORE_REFRESH) + need_update = FULL; + else + need_update = what; + if ((need_update != CURSOR) || (TEXT(bv)->status != LyXText::UNCHANGED)) + bv->updateInset(this, mark_dirty); if (old_par != cpar(bv)) { bv->owner()->getToolbar()->combox->select(cpar(bv)->GetLayout()+1); old_par = cpar(bv); diff --git a/src/insets/insettext.h b/src/insets/insettext.h index c61fffd0a4..50cfd1044e 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -45,6 +45,7 @@ public: INIT, FULL, CURSOR_PAR, + CURSOR, SELECTION }; /// @@ -71,7 +72,9 @@ public: /// int width(Painter &, LyXFont const & f) const; /// - void draw(BufferView *, LyXFont const &, int , float &) const; + int textWidth(Painter &) const; + /// + void draw(BufferView *, LyXFont const &, int , float &, bool) const; /// void update(BufferView *, LyXFont const &, bool =false); /// diff --git a/src/insets/lyxinset.h b/src/insets/lyxinset.h index 20117dae39..6f13fa4f83 100644 --- a/src/insets/lyxinset.h +++ b/src/insets/lyxinset.h @@ -116,7 +116,7 @@ public: virtual int width(Painter &, LyXFont const &) const = 0; /// virtual void draw(BufferView *, LyXFont const &, - int baseline, float & x) const = 0; + int baseline, float & x, bool cleared) const = 0; /// update the inset representation virtual void update(BufferView *, LyXFont const &, bool =false) {} diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 24aaf44d0c..f23bd3f3c8 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -215,7 +215,7 @@ int LyXFunc::processKeyEvent(XEvent * ev) owner->getMiniBuffer()->Set(CurrentState(owner->view())); } else { tli->UnlockInsetInInset(owner->view(), - tli->GetLockingInset()); + tli->GetLockingInset(),true); } return 0; } diff --git a/src/lyxparagraph.h b/src/lyxparagraph.h index 56f3df2c00..bafa4a29dc 100644 --- a/src/lyxparagraph.h +++ b/src/lyxparagraph.h @@ -31,6 +31,7 @@ class LyXBuffer; class TexRow; struct LaTeXFeatures; class InsetBibKey; +class BufferView; /// A LyXParagraph holds all text, attributes and insets in a text paragraph class LyXParagraph { @@ -195,7 +196,9 @@ public: /// Inset * InInset() { return inset_owner; } /// - void SetInsetOwner(Inset * i) { inset_owner = i; } + void SetInsetOwner(Inset * i); + /// + void deleteInsetsLyXText(BufferView *); private: /// TextContainer text; diff --git a/src/lyxtext.h b/src/lyxtext.h index c5ea5c05f5..938752c3e0 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -610,7 +610,7 @@ private: /// void draw(BufferView *, Row const * row, LyXParagraph::size_type & pos, - int offset, float & x); + int offset, float & x, bool cleared); /// get the next breakpoint in a given paragraph LyXParagraph::size_type NextBreakPoint(BufferView *, Row const * row, diff --git a/src/mathed/formula.C b/src/mathed/formula.C index 4980f5c7d9..c27f4c293d 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -404,7 +404,7 @@ int InsetFormula::width(Painter &, LyXFont const & f) const void InsetFormula::draw(BufferView * bv, LyXFont const & f, - int baseline, float & x) const + int baseline, float & x, bool) const { Painter & pain = bv->painter(); // Seems commenting out solves a problem. diff --git a/src/mathed/formula.h b/src/mathed/formula.h index 5d96703cf3..41da55bfe6 100644 --- a/src/mathed/formula.h +++ b/src/mathed/formula.h @@ -47,7 +47,7 @@ public: /// int width(Painter &, LyXFont const &) const; /// - void draw(BufferView *,LyXFont const &, int baseline, float & x) const; + void draw(BufferView *,LyXFont const &, int, float &, bool) const; /// void Write(Buffer const *, std::ostream &) const; /// diff --git a/src/mathed/formulamacro.C b/src/mathed/formulamacro.C index 6f7e06bd8b..1ab86ff732 100644 --- a/src/mathed/formulamacro.C +++ b/src/mathed/formulamacro.C @@ -147,14 +147,14 @@ int InsetFormulaMacro::width(Painter & pain, LyXFont const & f) const void InsetFormulaMacro::draw(BufferView * bv, LyXFont const & f, - int baseline, float & x) const + int baseline, float & x, bool cleared) const { Painter & pain = bv->painter(); LyXFont font(f); tmacro->update(); if (opened) { tmacro->setEditMode(true); - InsetFormula::draw(bv, font, baseline, x); + InsetFormula::draw(bv, font, baseline, x, cleared); tmacro->setEditMode(false); } else { font.setColor(LColor::math); diff --git a/src/mathed/formulamacro.h b/src/mathed/formulamacro.h index ecbf0ea60e..2ae57cb6ee 100644 --- a/src/mathed/formulamacro.h +++ b/src/mathed/formulamacro.h @@ -43,7 +43,7 @@ public: /// int width(Painter &, LyXFont const &) const; /// - void draw(BufferView *,LyXFont const &, int baseline, float & x) const; + void draw(BufferView *,LyXFont const &, int, float &, bool) const; /// void Read(Buffer const *, LyXLex & lex); /// diff --git a/src/paragraph.C b/src/paragraph.C index 0ab5d688ed..75a48929e8 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -29,10 +29,12 @@ #include "LaTeXFeatures.h" #include "insets/insetinclude.h" #include "insets/insetbib.h" +#include "insets/insettext.h" #include "support/filetools.h" #include "lyx_gui_misc.h" #include "texrow.h" #include "support/lyxmanip.h" +#include "BufferView.h" using std::ostream; using std::endl; @@ -4373,3 +4375,29 @@ string LyXParagraph::String(Buffer const * buffer, return s; } + + +void LyXParagraph::SetInsetOwner(Inset *i) +{ + inset_owner = i; + for (InsetList::const_iterator cit = insetlist.begin(); + cit != insetlist.end(); ++cit) { + if ((*cit).inset) + (*cit).inset->setOwner(i); + } +} + + +void LyXParagraph::deleteInsetsLyXText(BufferView * bv) +{ + // then the insets + for (InsetList::const_iterator cit = insetlist.begin(); + cit != insetlist.end(); ++cit) { + if ((*cit).inset) { + if ((*cit).inset->IsTextInset()) { + static_cast((*cit).inset)-> + deleteLyXText(bv); + } + } + } +} diff --git a/src/tabular.C b/src/tabular.C index 7ebdeb6923..42853796d8 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -54,51 +54,8 @@ LyXTabular::cellstruct::cellstruct() bottom_line = false; rotate = false; linebreaks = false; -#ifdef INSET_POINTER - inset = 0; -#endif } -#ifdef INSET_POINTER -LyXTabular::cellstruct::~cellstruct() -{ - delete inset; -} - -LyXTabular::cellstruct::cellstruct(cellstruct const & cs) -{ - cellno = cs.cellno; - width_of_cell = cs.width_of_cell; - multicolumn = cs.multicolumn; - alignment = cs.alignment; - top_line = cs.top_line; - bottom_line = cs.bottom_line; - rotate = cs.rotate; - linebreaks = cs.linebreaks; - inset = cs.inset; -#if 0 - if (cs.inset) - inset = static_cast(cs.inset->Clone()); -#endif -} - -LyXTabular::cellstruct & -LyXTabular::cellstruct::operator=(cellstruct const & cs) -{ - cellno = cs.cellno; - width_of_cell = cs.width_of_cell; - multicolumn = cs.multicolumn; - alignment = cs.alignment; - top_line = cs.top_line; - bottom_line = cs.bottom_line; - rotate = cs.rotate; - linebreaks = cs.linebreaks; - if (cs.inset) - inset = static_cast(cs.inset->Clone()); - return *this; -} -#endif - LyXTabular::rowstruct::rowstruct() { @@ -186,12 +143,7 @@ LyXTabular * LyXTabular::Clone(InsetTabular * inset) int i,j; for(i=0; i < rows_; ++i) { for(j=0; j < columns_; ++j) { -#ifdef INSET_POINTER - delete result->cell_info[i][j].inset; - result->cell_info[i][j].inset=new InsetText(*cell_info[i][j].inset); -#else result->cell_info[i][j].inset = cell_info[i][j].inset; -#endif result->cell_info[i][j].inset.setOwner(inset); } } @@ -215,10 +167,6 @@ void LyXTabular::Init(int rows_arg, int columns_arg) // Jürgen, use iterators. for (i = 0; i < rows_; ++i) { for (j = 0; j < columns_; ++j) { -#ifdef INSET_POINTER - if (!cell_info[i][j].inset) - cell_info[i][j].inset = new InsetText(); -#endif cell_info[i][j].inset.setOwner(owner_); cell_info[i][j].inset.SetDrawLockedFrame(true); cell_info[i][j].cellno = cellno++; @@ -255,7 +203,7 @@ void LyXTabular::AppendRow(int cell ) row_vector::iterator rit = row_info.begin() + row; row_info.insert(rit, rowstruct()); -#if 1 +#if 0 cell_vvector::iterator cit = cell_info.begin() + row; cell_info.insert(cit, vector(columns_, cellstruct())); #else @@ -273,14 +221,6 @@ void LyXTabular::AppendRow(int cell ) } } cell_info = c_info; -#ifdef INSET_POINTER - for(int i = 0; i < rows_; ++i) { - for(int j = 0; j < columns_; ++j) { - if (!cell_info[i][j].inset) - cell_info[i][j].inset = static_cast(c_info[i][j].inset->Clone()); - } - } -#endif ++row; for (int j = 0; j < columns_; ++j) { cell_info[row][j].inset.clear(); @@ -329,13 +269,6 @@ void LyXTabular::AppendColumn(int cell) } } cell_info = c_info; -#ifdef INSET_POINTER - for(i = 0; i < rows_; ++i) { - for(j = 0; j < columns_; ++j) { - cell_info[i][j].inset = static_cast(c_info[i][j].inset->Clone()); - } - } -#endif ++column; for (i = 0; i < rows_; ++i) { cell_info[i][column].inset.clear(); diff --git a/src/text.C b/src/text.C index 408872d492..d77d5f4644 100644 --- a/src/text.C +++ b/src/text.C @@ -117,12 +117,7 @@ bool is_nikud(unsigned char c) int LyXText::workWidth(BufferView * bview) const { if (inset_owner) { -#if 1 - return inset_owner->getMaxWidth(bview->painter(), inset_owner); -#else - LyXFont font(LyXFont::ALL_SANE); - return inset_owner->width(bview->painter(), font); -#endif + return inset_owner->textWidth(bview->painter()); } return bview->workWidth(); } @@ -445,7 +440,7 @@ bool LyXText::IsBoundary(Buffer const * buf, LyXParagraph * par, void LyXText::draw(BufferView * bview, Row const * row, LyXParagraph::size_type & vpos, - int offset, float & x) + int offset, float & x, bool cleared) { Painter & pain = bview->painter(); @@ -567,7 +562,8 @@ void LyXText::draw(BufferView * bview, Row const * row, } else if (c == LyXParagraph::META_INSET) { Inset const * tmpinset = row->par()->GetInset(pos); if (tmpinset) { - tmpinset->draw(bview, font, offset+row->baseline(), x); + tmpinset->draw(bview, font, offset+row->baseline(), x, + cleared); } ++vpos; @@ -3794,10 +3790,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, // clear the area where we want to paint/print int ww; - if (inset_owner) - ww = inset_owner->width(bview->painter(), font) - 1; - else - ww = bview->workWidth(); + ww = bview->workWidth(); bool clear_area = true; @@ -3807,8 +3800,14 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, { clear_area = row_ptr->par()->GetInset(row_ptr->pos())->doClearArea(); } - if (clear_area) - pain.fillRectangle(x_offset, y_offset, ww, row_ptr->height()); + if (clear_area) { + int w; + if (inset_owner) + w = inset_owner->width(bview->painter(), font); + else + w = ww; + pain.fillRectangle(x_offset, y_offset, w, row_ptr->height()); + } if (selection) { /* selection code */ @@ -4324,7 +4323,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, - row_ptr->par()->bibkey->width(bview->painter(), font); row_ptr->par()->bibkey->draw(bview, font, y_offset + row_ptr->baseline(), - tmpx); + tmpx, clear_area); } } @@ -4528,7 +4527,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, row_ptr->par(), pos); ++vpos; } else - draw(bview, row_ptr, vpos, y_offset, x); + draw(bview, row_ptr, vpos, y_offset, x, clear_area); } /* do not forget the very last cell. This has no NEWLINE so @@ -4640,7 +4639,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, x += fill_separator; ++vpos; } else - draw(bview, row_ptr, vpos, y_offset, x); + draw(bview, row_ptr, vpos, y_offset, x, clear_area); } #ifndef NEW_TABULAR } diff --git a/src/text2.C b/src/text2.C index ed1aad2b32..ab6d84ba49 100644 --- a/src/text2.C +++ b/src/text2.C @@ -69,7 +69,8 @@ void LyXText::init() lastrow = 0; number_of_rows = 0; refresh_y = 0; - height = width = 0; + height = 0; + width = -1; first = 0; status = LyXText::UNCHANGED; // set cursor at the very top position @@ -131,7 +132,7 @@ void LyXText::init(BufferView * bview) par = par->Next(); } SetCursorIntern(bview, firstrow->par(), 0); -#if 1 +#if 0 // Dump all rowinformation: Row * tmprow = firstrow; lyxerr << "Width = " << width << endl;