]> git.lyx.org Git - features.git/commitdiff
some more infrastructure...
authorAndré Pönitz <poenitz@gmx.net>
Tue, 22 Jul 2003 11:54:39 +0000 (11:54 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Tue, 22 Jul 2003 11:54:39 +0000 (11:54 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7343 a592a061-630c-0410-9148-cb99ea01b6c8

src/lyxtext.h
src/rowpainter.C
src/text.C

index a4841b1a1c356ec0ad74f30750f9db11457b21ab..bde466f798eabb49e1242971aece17efd2d6fc1d 100644 (file)
@@ -470,11 +470,12 @@ public:
        Inset * checkInsetHit(int & x, int & y);
 
        ///
-       int singleWidth(ParagraphList::iterator pit,
-               lyx::pos_type pos) const;
+       int singleWidth(ParagraphList::iterator pit, lyx::pos_type pos) const;
        ///
        int singleWidth(ParagraphList::iterator pit,
                lyx::pos_type pos, char c) const;
+       /// rebuild row cache
+       void rebuildRows();
 
        /// return the color of the canvas
        LColor::color backgroundColor() const;
index 493b8f683735517dd43851080e2b1251f36caa6d..c95b9f7d073457fd46aca315b6ccea94bed1dacf 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "insets/insettext.h"
 #include "ParagraphParameters.h"
+#include "debug.h"
 #include "BufferView.h"
 #include "buffer.h"
 #include "gettext.h"
@@ -178,10 +179,6 @@ void RowPainter::paintInset(pos_type const pos)
 
        Assert(inset);
 
-       //MetricsInfo mi(perv(bv_), getFont(pos), text_.workWidth());
-       //Dimension dim; 
-       //inset->metrics(mi, dim);
-
        PainterInfo pi(perv(bv_));
        pi.base.font = getFont(pos);
 #warning metrics?
@@ -309,6 +306,8 @@ void RowPainter::paintChars(pos_type & vpos, bool hebrew, bool arabic)
        }
 
        // Draw text and set the new x position
+       lyxerr << "paint row: yo_ " << yo_ << " baseline: " << row_->baseline()
+               << "\n";
        pain_.text(int(x_), yo_ + row_->baseline(), str, orig_font);
        x_ += font_metrics::width(str, orig_font);
 }
@@ -949,8 +948,7 @@ void RowPainter::paintText()
                        int const lwidth = font_metrics::width(layout->labelsep,
                                getLabelFont());
 
-                       x_ += label_hfill_ + lwidth
-                               - singleWidth(body_pos - 1);
+                       x_ += label_hfill_ + lwidth - singleWidth(body_pos - 1);
                }
 
                if (pit_->isHfill(pos)) {
@@ -959,8 +957,7 @@ void RowPainter::paintText()
                        int const y0 = yo_ + row_->baseline();
                        int const y1 = y0 - defaultRowHeight() / 2;
 
-                       pain_.line(x_, y1, x_, y0,
-                                    LColor::added_space);
+                       pain_.line(x_, y1, x_, y0, LColor::added_space);
 
                        if (hfillExpansion(text_, row_, pos)) {
                                int const y2 = (y0 + y1) / 2;
@@ -1075,6 +1072,34 @@ int getLengthMarkerHeight(BufferView const & bv, VSpace const & vsp)
 void paintRows(BufferView const & bv, LyXText const & text,
        RowList::iterator rit, int y_offset, int x_offset, int y)
 {
+       // fix up missing metrics() call for main LyXText
+       // calling metrics() directly is (a) slow and (b) crashs
+       if (&text == bv.text) {
+#if 1
+               lyxerr << "paintRows, global...\n";
+               // make sure all insets are updated
+               ParagraphList::iterator pit = text.ownerParagraphs().begin();
+               ParagraphList::iterator end = text.ownerParagraphs().end();
+
+               // compute inset metrics
+               for (; pit != end; ++pit) {
+                       for (int pos = 0; pos != pit->size(); ++pos) {
+                               if (pit->isInset(pos)) {
+                                       Dimension dim;
+                                       LyXFont font;
+                                       MetricsInfo mi(perv(bv), font, text.workWidth());
+                                       pit->getInset(pos)->metrics(mi, dim);
+                               }
+                       }
+               }
+#else
+               LyXFont font;
+               Dimension dim;
+               MetricsInfo mi(perv(bv), font, text.workWidth());
+               const_cast<LyXText&>(text).metrics(mi, dim);
+#endif
+       }
+
        RowPainter painter(bv, text, rit, y_offset, x_offset, y);
        painter.paint();
 }
index beee680ef0ebd38f3ec361d5d7b824b31c5bb9e3..1ef7d2439faabbca24a732a13ed43b3b9463f1c1 100644 (file)
@@ -311,7 +311,7 @@ int LyXText::singleWidth(ParagraphList::iterator pit,
                                // Because of the representation as vertical lines
                                return 3;
                        }
-#if 1
+#if 0
 #warning inset->update FIXME
                        // this IS needed otherwise on initialitation we don't get the fill
                        // of the row right (ONLY on initialization if we read a file!)
@@ -1079,7 +1079,7 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
                                tmpfont = getFont(bv()->buffer(), pit, pos);
                                tmpinset = pit->getInset(pos);
                                if (tmpinset) {
-#if 0 // this is needed for deep update on initialitation
+#if 1 // this is needed for deep update on initialitation
 #warning inset->update FIXME
                                        //tmpinset->update(bv());
                                        Dimension dim;