Could anybody please have a look whether there are any drawing issues with that patch?
Andre' -- Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. (T. Jefferson or B. Franklin or both...)
Index: rowpainter.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/rowpainter.C,v retrieving revision 1.18 diff -u -p -r1.18 rowpainter.C --- rowpainter.C 30 May 2003 06:48:20 -0000 1.18 +++ rowpainter.C 17 Jun 2003 11:04:20 -0000 @@ -104,14 +104,18 @@ void RowPainter::paintInset(pos_type con lyx::Assert(inset); -#warning inset->update FIXME - inset->update(perv(bv_), false); + MetricsInfo mi; + mi.base.bv = perv(bv_); + mi.base.font = getFont(pos); + + Dimension dim; + inset->metrics(mi, dim); PainterInfo pi(perv(bv_)); - pi.base.font = getFont(pos); - int const w = inset->width(perv(bv_), pi.base.font); + //pi.base.font = getFont(pos); + //int const w = inset->width(perv(bv_), pi.base.font); inset->draw(pi, int(x_), yo_ + row_->baseline()); - x_ += w; + x_ += dim.wid; } Index: text.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v retrieving revision 1.367 diff -u -p -r1.367 text.C --- text.C 12 Jun 2003 11:09:53 -0000 1.367 +++ text.C 17 Jun 2003 11:04:20 -0000 @@ -33,6 +33,7 @@ #include "WordLangTuple.h" #include "paragraph_funcs.h" #include "rowpainter.h" +#include "metricsinfo.h" #include "lyxrow_funcs.h" #include "insets/insettext.h" @@ -310,9 +311,15 @@ int LyXText::singleWidth(ParagraphList:: // 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(bv()); + //tmpinset->update(bv()); #endif - return tmpinset->width(bv(), font); + //return tmpinset->width(bv(), font); + MetricsInfo mi; + mi.base.bv = bv(); + mi.base.font = font; + Dimension dim; + tmpinset->metrics(mi, dim); + return dim.wid; } return 0; } @@ -1070,13 +1077,21 @@ void LyXText::setHeightOfRow(RowList::it if (tmpinset) { #if 1 // this is needed for deep update on initialitation #warning inset->update FIXME - tmpinset->update(bv()); + //tmpinset->update(bv()); #endif - maxwidth += tmpinset->width(bv(), tmpfont); - maxasc = max(maxasc, - tmpinset->ascent(bv(), tmpfont)); - maxdesc = max(maxdesc, - tmpinset->descent(bv(), tmpfont)); + //maxwidth += tmpinset->width(bv(), tmpfont); + //maxasc = max(maxasc, + // tmpinset->ascent(bv(), tmpfont)); + //maxdesc = max(maxdesc, + // tmpinset->descent(bv(), tmpfont)); + MetricsInfo mi; + mi.base.bv = bv(); + mi.base.font = tmpfont; + Dimension dim; + tmpinset->metrics(mi, dim); + maxwidth += dim.wid; + maxasc = max(maxasc, dim.asc); + maxdesc = max(maxdesc, dim.des); } } else { maxwidth += singleWidth(pit, pos); Index: insets/inset.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/inset.h,v retrieving revision 1.101 diff -u -p -r1.101 inset.h --- insets/inset.h 16 Jun 2003 11:49:30 -0000 1.101 +++ insets/inset.h 17 Jun 2003 11:04:20 -0000 @@ -160,9 +160,6 @@ public: int descent(BufferView *, LyXFont const &) const; /// int width(BufferView *, LyXFont const &) const; - /// update the inset representation - virtual void update(BufferView *, bool = false) - {} /// what appears in the minibuffer when opening virtual string const editMessage() const; /// Index: insets/insetcollapsable.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcollapsable.C,v retrieving revision 1.148 diff -u -p -r1.148 insetcollapsable.C --- insets/insetcollapsable.C 16 Jun 2003 11:49:30 -0000 1.148 +++ insets/insetcollapsable.C 17 Jun 2003 11:04:21 -0000 @@ -286,6 +286,7 @@ int InsetCollapsable::docbook(Buffer con } +#if 0 void InsetCollapsable::update(BufferView * bv, bool reinit) { if (in_update) { @@ -301,6 +302,7 @@ void InsetCollapsable::update(BufferView } in_update = false; } +#endif Inset::RESULT InsetCollapsable::localDispatch(FuncRequest const & cmd) Index: insets/insetcollapsable.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcollapsable.h,v retrieving revision 1.110 diff -u -p -r1.110 insetcollapsable.h --- insets/insetcollapsable.h 16 Jun 2003 11:49:30 -0000 1.110 +++ insets/insetcollapsable.h 17 Jun 2003 11:04:21 -0000 @@ -51,8 +51,6 @@ public: /// draw, either inlined (no button) or collapsed/open void draw(PainterInfo & pi, int x, int y, bool inlined) const; /// - void update(BufferView *, bool = false); - /// EDITABLE editable() const; /// bool insertInset(BufferView *, Inset * inset); Index: insets/insetert.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetert.C,v retrieving revision 1.131 diff -u -p -r1.131 insetert.C --- insets/insetert.C 16 Jun 2003 11:49:30 -0000 1.131 +++ insets/insetert.C 17 Jun 2003 11:04:21 -0000 @@ -456,7 +456,7 @@ Inset::RESULT InsetERT::localDispatch(Fu t->need_break_row = t->rows().begin(); t->fullRebreak(); t->setCursorIntern(t->cursor.par(), t->cursor.pos()); - inset.update(cmd.view(), true); + //inset.update(cmd.view(), true); bv->updateInset(this); result = DISPATCHED; } @@ -554,6 +554,7 @@ bool InsetERT::checkInsertChar(LyXFont & void InsetERT::metrics(MetricsInfo & mi, Dimension & dim) const { + setButtonLabel(); if (inlined()) inset.metrics(mi, dim); else @@ -664,17 +665,6 @@ int InsetERT::getMaxWidth(BufferView * b if (text->rows().size() == 1 && rw < w) return -1; return w; -} - - -void InsetERT::update(BufferView * bv, bool reinit) -{ - if (inset.need_update & InsetText::INIT || - inset.need_update & InsetText::FULL) { - setButtonLabel(); - } - - InsetCollapsable::update(bv, reinit); } Index: insets/insetert.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetert.h,v retrieving revision 1.76 diff -u -p -r1.76 insetert.h --- insets/insetert.h 16 Jun 2003 11:49:31 -0000 1.76 +++ insets/insetert.h 17 Jun 2003 11:04:21 -0000 @@ -114,8 +114,6 @@ public: } /// int getMaxWidth(BufferView *, UpdatableInset const *) const; - /// - void update(BufferView *, bool =false); private: /// Index: insets/insetminipage.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetminipage.C,v retrieving revision 1.78 diff -u -p -r1.78 insetminipage.C --- insets/insetminipage.C 16 Jun 2003 11:49:31 -0000 1.78 +++ insets/insetminipage.C 17 Jun 2003 11:04:21 -0000 @@ -121,7 +121,7 @@ dispatch_result InsetMinipage::localDisp LyXText * t = inset.getLyXText(cmd.view()); t->need_break_row = t->rows().begin(); t->fullRebreak(); - inset.update(cmd.view(), true); + //inset.update(cmd.view(), true); t->setCursorIntern(t->cursor.par(), t->cursor.pos()); cmd.view()->updateInset(this); return DISPATCHED; Index: insets/insettabular.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.C,v retrieving revision 1.290 diff -u -p -r1.290 insettabular.C --- insets/insettabular.C 16 Jun 2003 11:49:32 -0000 1.290 +++ insets/insettabular.C 17 Jun 2003 11:04:21 -0000 @@ -245,9 +245,49 @@ void InsetTabular::read(Buffer const * b } -void InsetTabular::metrics(MetricsInfo &, - Dimension & dim) const +void InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const { + int cell = -1; + int maxAsc = 0; + int maxDesc = 0; + InsetText * inset; + + // FIXME: since InsetText ignores this anyway, it doesn't + // matter what we pass it. Ugly + LyXFont font; + + // if we have a locking_inset we should have to check only this cell for + // change so I'll try this to have a boost, but who knows ;) + for (int i = 0; i < tabular.rows(); ++i) { + maxAsc = 0; + maxDesc = 0; + for (int j = 0; j < tabular.columns(); ++j) { + if (tabular.isPartOfMultiColumn(i,j)) + continue; + ++cell; + inset = tabular.getCellInset(cell); + Dimension dim; + MetricsInfo m = mi; + LyXLength len = tabular.getPWidth(cell); + if (!len.zero()) { + m.base.restrictwidth = true; + m.base.textwidth = len.inPixels(mi.base.textwidth); + //lyxerr << "InsetTabular: cell of bounded width: " + // << len.asString() << "\n"; + } + inset->metrics(m, dim); + //if (!reinit && !tabular.getPWidth(cell).zero()) + // inset->update(bv, false); + maxAsc = max(maxAsc, inset->ascent(mi.base.bv, font)); + maxDesc = max(maxDesc, inset->descent(mi.base.bv, font)); + tabular.setWidthOfCell(cell, inset->width(mi.base.bv, font)); + } + tabular.setAscentOfRow(i, maxAsc + ADD_TO_HEIGHT); + tabular.setDescentOfRow(i, maxDesc + ADD_TO_HEIGHT); + } + tabular.reinit(); + + resetPos(mi.base.bv); dim.asc = tabular.getAscentOfRow(0); dim.des = tabular.getHeightOfTabular() - tabular.getAscentOfRow(0) + 1; dim.wid = tabular.getWidthOfTabular() + 2 * ADD_TO_TABULAR_WIDTH; @@ -391,8 +431,13 @@ void InsetTabular::drawCellSelection(Pai } +/* void InsetTabular::update(BufferView * bv, bool reinit) { + static int count = 0; + ++count; + + lyxerr << "InsetTabular::update(): " << count << "\n"; if (in_update) { if (reinit) { resetPos(bv); @@ -436,6 +481,8 @@ void InsetTabular::update(BufferView * b } in_update = false; } +*/ + string const InsetTabular::editMessage() const @@ -1258,13 +1305,13 @@ void InsetTabular::validate(LaTeXFeature } -bool InsetTabular::calculate_dimensions_of_cells(BufferView * bv, bool reinit) const +bool InsetTabular::calculate_dimensions_of_cells + (BufferView * bv, bool reinit) const { int cell = -1; int maxAsc = 0; int maxDesc = 0; InsetText * inset; - bool changed = false; // FIXME: since InsetText ignores this anyway, it doesn't // matter what we pass it. Ugly @@ -1272,19 +1319,6 @@ bool InsetTabular::calculate_dimensions_ // if we have a locking_inset we should have to check only this cell for // change so I'll try this to have a boost, but who knows ;) - if ((need_update != INIT) && - (the_locking_inset == tabular.getCellInset(actcell))) { - for(int i = 0; i < tabular.columns(); ++i) { - maxAsc = max(tabular.getCellInset(actrow, i)->ascent(bv, font), - maxAsc); - maxDesc = max(tabular.getCellInset(actrow, i)->descent(bv, font), - maxDesc); - } - changed = tabular.setWidthOfCell(actcell, the_locking_inset->width(bv, font)); - changed = tabular.setAscentOfRow(actrow, maxAsc + ADD_TO_HEIGHT) || changed; - changed = tabular.setDescentOfRow(actrow, maxDesc + ADD_TO_HEIGHT) || changed; - return changed; - } for (int i = 0; i < tabular.rows(); ++i) { maxAsc = 0; maxDesc = 0; @@ -1293,18 +1327,17 @@ bool InsetTabular::calculate_dimensions_ continue; ++cell; inset = tabular.getCellInset(cell); - if (!reinit && !tabular.getPWidth(cell).zero()) - inset->update(bv, false); + //if (!reinit && !tabular.getPWidth(cell).zero()) + // inset->update(bv, false); maxAsc = max(maxAsc, inset->ascent(bv, font)); maxDesc = max(maxDesc, inset->descent(bv, font)); - changed = tabular.setWidthOfCell(cell, inset->width(bv, font)) || changed; + tabular.setWidthOfCell(cell, inset->width(bv, font)); } - changed = tabular.setAscentOfRow(i, maxAsc + ADD_TO_HEIGHT) || changed; - changed = tabular.setDescentOfRow(i, maxDesc + ADD_TO_HEIGHT) || changed; + tabular.setAscentOfRow(i, maxAsc + ADD_TO_HEIGHT); + tabular.setDescentOfRow(i, maxDesc + ADD_TO_HEIGHT); } - if (changed) - tabular.reinit(); - return changed; + tabular.reinit(); + return true; } Index: insets/insettabular.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.h,v retrieving revision 1.126 diff -u -p -r1.126 insettabular.h --- insets/insettabular.h 16 Jun 2003 11:49:33 -0000 1.126 +++ insets/insettabular.h 17 Jun 2003 11:04:21 -0000 @@ -87,8 +87,6 @@ public: /// void draw(PainterInfo & pi, int x, int y) const; /// - void update(BufferView *, bool = false); - /// string const editMessage() const; // void insetUnlock(BufferView *); Index: insets/insettext.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.C,v retrieving revision 1.407 diff -u -p -r1.407 insettext.C --- insets/insettext.C 16 Jun 2003 11:49:33 -0000 1.407 +++ insets/insettext.C 17 Jun 2003 11:04:21 -0000 @@ -289,13 +289,22 @@ void InsetText::read(Buffer const * buf, void InsetText::metrics(MetricsInfo & mi, Dimension & dim) const { + //lyxerr << "InsetText: metrics: " << mi.base.textwidth << "\n"; BufferView * bv = mi.base.bv; LyXText * text = getLyXText(bv); + if (mi.base.restrictwidth) { + //lyxerr << "InsetText: bounded width: " << mi.base.textwidth << "\n"; + old_max_width = mi.base.textwidth; + last_drawn_width = mi.base.textwidth; + lt ? lt->init(bv, true) : getLyXText(bv)->init(bv, true); + } dim.asc = text->rows().begin()->ascent_of_text() + TEXT_TO_INSET_OFFSET; dim.des = text->height - dim.asc + TEXT_TO_INSET_OFFSET; dim.wid = max(textWidth(bv), int(text->width)) + 2 * TEXT_TO_INSET_OFFSET; dim.wid = max(dim.wid, 10); dim_ = dim; + //textwidth_ = mi.base.textwidth; + //restrictwidth_ = mi.base.restrictwidth; } @@ -303,12 +312,14 @@ int InsetText::textWidth(BufferView * bv { int w = autoBreakRows ? getMaxWidth(bv, this) : -1; +/* if (fordraw) return max(w - 2 * TEXT_TO_INSET_OFFSET, (int)getLyXText(bv)->width); if (w < 0) return -1; +*/ return w - 2 * TEXT_TO_INSET_OFFSET; } @@ -316,8 +327,12 @@ int InsetText::textWidth(BufferView * bv void InsetText::draw(PainterInfo & pi, int x, int baseline) const { - if (nodraw()) - return; + //if (nodraw()) + // return; + + //MetricsInfo mi; + //mi.base = pi.base; + //metrics(mi, dim_); // update our idea of where we are. Clearly, we should // not have to know this information. @@ -426,6 +441,7 @@ void InsetText::drawFrame(Painter & pain } +/* void InsetText::update(BufferView * bv, bool reinit) { if (in_update) { @@ -486,6 +502,7 @@ void InsetText::update(BufferView * bv, old_max_width = nw; } } +*/ void InsetText::setUpdateStatus(BufferView * bv, int what) const @@ -1905,7 +1922,7 @@ bool InsetText::checkAndActivateInset(Bu int InsetText::getMaxWidth(BufferView * bv, UpdatableInset const * inset) const { -#if 0 +#if 1 int w = UpdatableInset::getMaxWidth(bv, inset); if (w < 0) { return -1; Index: insets/insettext.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.h,v retrieving revision 1.168 diff -u -p -r1.168 insettext.h --- insets/insettext.h 16 Jun 2003 11:49:34 -0000 1.168 +++ insets/insettext.h 17 Jun 2003 11:04:21 -0000 @@ -90,8 +90,6 @@ public: /// void draw(PainterInfo & pi, int x, int y) const; /// - void update(BufferView *, bool = false); - /// void setUpdateStatus(BufferView *, int what) const; /// string const editMessage() const;