]> git.lyx.org Git - features.git/commitdiff
the lyxrow changes including accessors.
authorAndré Pönitz <poenitz@gmx.net>
Fri, 22 Aug 2003 09:40:56 +0000 (09:40 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Fri, 22 Aug 2003 09:40:56 +0000 (09:40 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7583 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/lyxrow.C
src/lyxrow.h
src/lyxtext.h
src/rowpainter.C
src/text.C
src/text2.C

index 23e72dca2f4171a4e08148b9cc70ea3876ac0603..592bfbcd4c630cc594df187add226b4197adb69d 100644 (file)
@@ -1,4 +1,13 @@
 
+2003-08-22  André Pönitz  <poenitz@gmx.net>
+
+       * lyxrow.[Ch]: add x_ and *fill_ members
+
+       * lyxtext.h: 
+       * text.C:
+       * rowpainter.C:
+       * text2.C: adjust/remove prepareToPrint() calls
+
 2003-08-22  André Pönitz  <poenitz@gmx.net>
 
        * lyxrow.[Ch]: add  end_ member
@@ -12,6 +21,7 @@
 
        * text.C (redoParagraph): simplify row breaking logic
 
+
 2003-08-19  André Pönitz  <poenitz@gmx.net>
 
        * funcrequest.C: initialize button_ member
index 40adfda74840f3bb25ce44dd84b84cacde57e842..0881c62d4c770ea590fff58d5a5bcd7a7247ed58 100644 (file)
@@ -22,13 +22,15 @@ using std::min;
 
 Row::Row()
        : pos_(0), end_(0), fill_(0), height_(0), width_(0), y_(0),
-         ascent_of_text_(0), baseline_(0)
+         ascent_of_text_(0), baseline_(0),
+         x_(0), fill_separator_(0), fill_hfill_(0), fill_label_hfill_(0)
 {}
 
 
 Row::Row(pos_type pos)
        : pos_(pos), end_(0), fill_(0), height_(0), width_(0), y_(0),
-         ascent_of_text_(0), baseline_(0)
+         ascent_of_text_(0), baseline_(0),
+         x_(0), fill_separator_(0), fill_hfill_(0), fill_label_hfill_(0)
 {}
 
 
@@ -140,6 +142,54 @@ unsigned int Row::baseline() const
 }
 
 
+float Row::x() const
+{
+       return x_;
+}
+
+
+void Row::x(float f)
+{
+       x_ = f;
+}
+
+
+float Row::fill_separator() const
+{
+       return fill_separator_;
+}
+
+
+void Row::fill_separator(float f)
+{
+       fill_separator_ = f;
+}
+
+
+float Row::fill_hfill() const
+{
+       return fill_hfill_;
+}
+
+
+void Row::fill_hfill(float f)
+{
+       fill_hfill_ = f;
+}
+
+
+float Row::fill_label_hfill() const
+{
+       return fill_label_hfill_;
+}
+
+
+void Row::fill_label_hfill(float f)
+{
+       fill_label_hfill_ = f;
+}
+
+
 bool Row::isParStart() const
 {
        return !pos();
index 7c6fbf75269507715023e065eab680182bd3a509..6380fabde1f6538f3af5ba37a0056fe9b905febf 100644 (file)
@@ -62,6 +62,22 @@ public:
        unsigned int y() const;
        /// cache the y position
        void y(unsigned int newy);
+       ///
+       float x() const;
+       ///
+       void x(float);
+       ///
+       float fill_separator() const;
+       ///
+       void fill_separator(float);
+       ///
+       float fill_hfill() const;
+       ///
+       void fill_hfill(float);
+       ///
+       float fill_label_hfill() const;
+       ///
+       void fill_label_hfill(float);
        /// current debugging only
        void dump(const char * = "") const;
 private:
@@ -84,6 +100,14 @@ private:
        unsigned int top_of_text_;
        ///
        unsigned int baseline_;
+       /// offet from left border
+       float x_;
+       ///
+       float fill_separator_;
+       ///
+       float fill_hfill_;
+       ///
+       float fill_label_hfill_;
 };
 
 #endif
index ca313e558f4e18046e57afab08f713816b12921a..ccf137b1e29088712a52d6e13d3677e8cf09c200 100644 (file)
@@ -425,13 +425,8 @@ public:
 
        /** this calculates the specified parameters. needed when setting
         * the cursor and when creating a visible row */
-       void prepareToPrint(
-               ParagraphList::iterator pit,
-               RowList::iterator row, double & x,
-                           double & fill_separator,
-                           double & fill_hfill,
-                           double & fill_label_hfill,
-                           bool bidi = true) const;
+       void prepareToPrint(ParagraphList::iterator pit,
+               RowList::iterator row) const;
 
 private:
        ///
index e0a14df12cfd7f6b81af528341d2c0e4ea7a0a51..199ffd05aad402fb9df2898dc6c2c5c766d567bd 100644 (file)
@@ -1002,11 +1002,11 @@ void RowPainter::paintText()
 
 void RowPainter::paint()
 {
-       width_ = text_.workWidth();
-
-       // FIXME: must be a cleaner way here. Aren't these calculations
-       // belonging to row metrics ?
-       text_.prepareToPrint(pit_, row_, x_, separator_, hfill_, label_hfill_);
+       width_       = text_.workWidth();
+       x_           = row_->x();
+       separator_   = row_->fill_separator();
+       hfill_       = row_->fill_hfill();
+       label_hfill_ = row_->fill_label_hfill();
 
        // FIXME: what is this fixing ?
        if (text_.isInInset() && x_ < 0)
index 235e74aaef7808ff69898aa6ca0536debbd598fb..acb3710d0034614b808343875a238cf96be5557e 100644 (file)
@@ -721,6 +721,10 @@ pos_type LyXText::rowBreakPoint(ParagraphList::iterator pit,
                }
 
                char const c = pit->getChar(i);
+               if (i > endPosOfFontSpan) {
+                       font = getFont(pit, i);
+                       endPosOfFontSpan = pit->getEndPosOfFontSpan(i);
+               }
 
                int thiswidth;
 
@@ -1230,10 +1234,13 @@ void LyXText::setHeightOfRow(ParagraphList::iterator pit, RowList::iterator rit)
 
        double x = 0;
        if (layout->margintype != MARGIN_RIGHT_ADDRESS_BOX) {
+#warning needed?
+#if 0
                // this IS needed
                rit->width(maxwidth);
                double dummy;
                prepareToPrint(pit, rit, x, dummy, dummy, dummy, false);
+#endif
        }
        rit->width(int(maxwidth + x));
        if (inset_owner) {
@@ -1449,7 +1456,7 @@ void LyXText::insertChar(char c)
 
 void LyXText::charInserted()
 {
-       // Here we could call FinishUndo for every 20 characters inserted.
+       // Here we could call finishUndo for every 20 characters inserted.
        // This is from my experience how emacs does it. (Lgb)
        static unsigned int counter;
        if (counter < 20) {
@@ -1462,17 +1469,13 @@ void LyXText::charInserted()
 
 
 void LyXText::prepareToPrint(ParagraphList::iterator pit,
-           RowList::iterator rit, double & x,
-                            double & fill_separator,
-                            double & fill_hfill,
-                            double & fill_label_hfill,
-                            bool bidi) const
+           RowList::iterator const rit) const
 {
        double w = rit->fill();
-       fill_hfill = 0;
-       fill_label_hfill = 0;
-       fill_separator = 0;
-       fill_label_hfill = 0;
+       double fill_hfill = 0;
+       double fill_label_hfill = 0;
+       double fill_separator = 0;
+       double x = 0;
 
        bool const is_rtl =
                pit->isRightToLeftPar(bv()->buffer()->params);
@@ -1563,8 +1566,6 @@ void LyXText::prepareToPrint(ParagraphList::iterator pit,
                        break;
                }
        }
-       if (!bidi)
-               return;
 
        computeBidiTables(pit, bv()->buffer(), rit);
        if (is_rtl) {
@@ -1572,13 +1573,18 @@ void LyXText::prepareToPrint(ParagraphList::iterator pit,
                pos_type last = lastPos(*pit, rit);
 
                if (body_pos > 0 &&
-                   (body_pos - 1 > last ||
-                    !pit->isLineSeparator(body_pos - 1))) {
+                               (body_pos - 1 > last ||
+                                !pit->isLineSeparator(body_pos - 1))) {
                        x += font_metrics::width(layout->labelsep, getLabelFont(pit));
                        if (body_pos - 1 <= last)
                                x += fill_label_hfill;
                }
        }
+
+       rit->fill_hfill(fill_hfill);
+       rit->fill_label_hfill(fill_label_hfill);
+       rit->fill_separator(fill_separator);
+       rit->x(x);
 }
 
 
index 6c644bd944fa3369f928fdb64b8a24672b4da0cf..e16a58724e4d687530231931322546893d641545 100644 (file)
@@ -566,6 +566,7 @@ void LyXText::redoParagraph(ParagraphList::iterator pit)
        // set height and fill of rows
        for (rit = pit->rows.begin(); rit != end; ++rit) {
                rit->fill(fill(pit, rit, workWidth()));
+               prepareToPrint(pit, rit);
                setHeightOfRow(pit, rit);
        }
 
@@ -1404,16 +1405,12 @@ void LyXText::setCursor(LyXCursor & cur, ParagraphList::iterator pit,
 float LyXText::getCursorX(ParagraphList::iterator pit, RowList::iterator rit,
                          pos_type pos, pos_type last, bool boundary) const
 {
-       pos_type cursor_vpos = 0;
-       double x;
-       double fill_separator;
-       double fill_hfill;
-       double fill_label_hfill;
-       // This call HAS to be here because of the BidiTables!!!
-       prepareToPrint(pit, rit, x, fill_separator, fill_hfill,
-                      fill_label_hfill);
-
-       pos_type const rit_pos = rit->pos();
+       pos_type cursor_vpos    = 0;
+       double x                = rit->x();
+       double fill_separator   = rit->fill_separator();
+       double fill_hfill       = rit->fill_hfill();
+       double fill_label_hfill = rit->fill_label_hfill();
+       pos_type const rit_pos  = rit->pos();
 
        if (last < rit_pos)
                cursor_vpos = rit_pos;
@@ -1513,12 +1510,10 @@ void LyXText::setCurrentFont()
 pos_type LyXText::getColumnNearX(ParagraphList::iterator pit,
        RowList::iterator rit, int & x, bool & boundary) const
 {
-       double tmpx = 0;
-       double fill_separator;
-       double fill_hfill;
-       double fill_label_hfill;
-
-       prepareToPrint(pit, rit, tmpx, fill_separator, fill_hfill, fill_label_hfill);
+       double tmpx             = rit->x();
+       double fill_separator   = rit->fill_separator();
+       double fill_hfill       = rit->fill_hfill();
+       double fill_label_hfill = rit->fill_label_hfill();
 
        pos_type vc = rit->pos();
        pos_type last = lastPrintablePos(*pit, rit);