]> git.lyx.org Git - features.git/commitdiff
prepare passing down max text widths...
authorAndré Pönitz <poenitz@gmx.net>
Thu, 17 Jul 2003 15:57:08 +0000 (15:57 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Thu, 17 Jul 2003 15:57:08 +0000 (15:57 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7309 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/insetbibitem.C
src/insets/insettabular.C
src/insets/insettext.C
src/lyxtext.h
src/text2.C

index 0ed0dc44bee4aa6ee1f51c7178af400a44eb3547..b9698e3d038585f23e62079e31c71d3428949691 100644 (file)
@@ -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;
        }
index 20b58e8e015f2a1e8ae6ec547dc18e790fb07792..35f367743c54bbb84364ed0c0c485eaf86400800 100644 (file)
@@ -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);
        }
index 1d3744d2ff39ac646b6bda4ad2f4ef2ee1741fc0..5b35e1cd0d55ec1d88981e167adbf759d0db2586 100644 (file)
@@ -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;
index 2e6ddd97c343df0830428b891686ecd3f74ba3c4..f967ee8a9c61c015a6eecdc1c72eed4cc4b0b5a8 100644 (file)
@@ -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;
index d183f53934bc81bd4b4f3956ca8ab179dfc3208a..fb161bc801cda4cd52473f89dc65ea59d3ada08f 100644 (file)
@@ -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());
 }