From: André Pönitz Date: Thu, 17 Jul 2003 15:57:08 +0000 (+0000) Subject: prepare passing down max text widths... X-Git-Tag: 1.6.10~16515 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=6da28005738baac67e539468bf6e72e136344669;p=features.git prepare passing down max text widths... git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7309 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/insets/insetbibitem.C b/src/insets/insetbibitem.C index 0ed0dc44be..b9698e3d03 100644 --- a/src/insets/insetbibitem.C +++ b/src/insets/insetbibitem.C @@ -73,12 +73,6 @@ dispatch_result InsetBibitem::localDispatch(FuncRequest const & cmd) setParams(p); cmd.view()->updateInset(this); - - // We need to do a redraw because the maximum - // InsetBibitem width could have changed -#warning please check you mean repaint() not update(), -#warning and whether the repaint() is needed at all - cmd.view()->repaint(); cmd.view()->fitCursor(); return DISPATCHED; } diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 20b58e8e01..35f367743c 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -256,14 +256,30 @@ void InsetTabular::read(Buffer const * buf, LyXLex & lex) void InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const { - if (mi.base.bv) { - calculate_dimensions_of_cells(mi.base.bv); - //lyxerr << "InsetTabular::metrics, bv: " << mi.base.bv << endl; - for (int i = 0; i < tabular.getNumberOfCells(); ++i) { - tabular.cellinfo_of_cell(i)->inset.text_.bv_owner = mi.base.bv; - tabular.cellinfo_of_cell(i)->inset.reinitLyXText(); - } - } + //lyxerr << "InsetTabular::metrics: " << mi.base.bv << " width: " << + // mi.base.textwidth << "\n"; + if (!mi.base.bv) { + lyxerr << "InsetTabular::metrics: need bv\n"; + Assert(0); + } + + calculate_dimensions_of_cells(mi.base.bv); + //lyxerr << "InsetTabular::metrics, bv: " << mi.base.bv << endl; + for (int i = 0; i < tabular.getNumberOfCells(); ++i) { + LyXTabular::cellstruct * ci = tabular.cellinfo_of_cell(i); + int col = tabular.column_of_cell(i); + InsetText & cell = ci->inset; + cell.text_.bv_owner = mi.base.bv; + int wid = tabular.column_info[col].p_width.inPixels(mi.base.textwidth); + //lyxerr << " " << i << " - " << ci->width_of_cell << " - " + // << tabular.column_info[col].width_of_column << " - " + // << wid << " "; + MetricsInfo m = mi; + m.base.textwidth = wid; + Dimension d; + cell.metrics(m, d); + } + //lyxerr << endl; dim.asc = tabular.getAscentOfRow(0); dim.des = tabular.getHeightOfTabular() - tabular.getAscentOfRow(0) + 1; @@ -273,6 +289,7 @@ void InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const void InsetTabular::draw(PainterInfo & pi, int x, int y) const { + lyxerr << "InsetTabular::draw: " << x << " " << y << "\n"; if (nodraw()) { need_update = FULL; return; @@ -436,6 +453,7 @@ void InsetTabular::insetUnlock(BufferView * bv) void InsetTabular::updateLocal(BufferView * bv, UpdateCodes what) const { + lyxerr << "InsetTabular::updateLocal: " << what << "\n"; if (what == INIT) { calculate_dimensions_of_cells(bv); } diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 1d3744d2ff..5b35e1cd0d 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -274,9 +274,10 @@ void InsetText::read(Buffer const * buf, LyXLex & lex) void InsetText::metrics(MetricsInfo & mi, Dimension & dim) const { + //lyxerr << "InsetText::metrics: width: " << mi.base.textwidth << "\n"; BufferView * bv = mi.base.bv; setViewCache(bv); - text_.rebuild(); + text_.rebuild(mi.base.textwidth); 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; diff --git a/src/lyxtext.h b/src/lyxtext.h index 2e6ddd97c3..f967ee8a9c 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -164,7 +164,7 @@ public: /// a full rebreak of the whole text void fullRebreak(); /// rebuild RowList cache - void rebuild(); + void rebuild(int maxwidth); /// RowList::iterator need_break_row; diff --git a/src/text2.C b/src/text2.C index d183f53934..fb161bc801 100644 --- a/src/text2.C +++ b/src/text2.C @@ -692,7 +692,7 @@ void LyXText::fullRebreak() } -void LyXText::rebuild() +void LyXText::rebuild(int maxwidth) { rowlist_.clear(); need_break_row = rows().end(); @@ -704,17 +704,15 @@ void LyXText::rebuild() ParagraphList::iterator pit = ownerParagraphs().begin(); ParagraphList::iterator end = ownerParagraphs().end(); - //current_font = getFont(bview->buffer(), pit, 0); - - for (; pit != end; ++pit) - insertParagraph(pit, rowlist_.end()); - - //setCursorIntern(rowlist_.begin()->par(), 0); - //selection.cursor = cursor; + for (; pit != end; ++pit) { + // insert a new row, starting at position 0 + Row newrow(pit, 0); + RowList::iterator rit = rowlist_.insert(rowlist_.end(), newrow); - //updateCounters(); + // and now append the whole paragraph before the new row + appendParagraph(rit); + } - //setCursorIntern(cursor.par(), cursor.pos()); }