From 0510f56da8d04ffb0e901fc913d254b6ff213048 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Fri, 22 Aug 2003 09:40:56 +0000 Subject: [PATCH] the lyxrow changes including accessors. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7583 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 10 +++++++++ src/lyxrow.C | 54 ++++++++++++++++++++++++++++++++++++++++++++++-- src/lyxrow.h | 24 +++++++++++++++++++++ src/lyxtext.h | 9 ++------ src/rowpainter.C | 10 ++++----- src/text.C | 34 +++++++++++++++++------------- src/text2.C | 27 ++++++++++-------------- 7 files changed, 124 insertions(+), 44 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 23e72dca2f..592bfbcd4c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,4 +1,13 @@ +2003-08-22 André Pönitz + + * 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 * lyxrow.[Ch]: add end_ member @@ -12,6 +21,7 @@ * text.C (redoParagraph): simplify row breaking logic + 2003-08-19 André Pönitz * funcrequest.C: initialize button_ member diff --git a/src/lyxrow.C b/src/lyxrow.C index 40adfda748..0881c62d4c 100644 --- a/src/lyxrow.C +++ b/src/lyxrow.C @@ -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(); diff --git a/src/lyxrow.h b/src/lyxrow.h index 7c6fbf7526..6380fabde1 100644 --- a/src/lyxrow.h +++ b/src/lyxrow.h @@ -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 diff --git a/src/lyxtext.h b/src/lyxtext.h index ca313e558f..ccf137b1e2 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -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: /// diff --git a/src/rowpainter.C b/src/rowpainter.C index e0a14df12c..199ffd05aa 100644 --- a/src/rowpainter.C +++ b/src/rowpainter.C @@ -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) diff --git a/src/text.C b/src/text.C index 235e74aaef..acb3710d00 100644 --- a/src/text.C +++ b/src/text.C @@ -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); } diff --git a/src/text2.C b/src/text2.C index 6c644bd944..e16a58724e 100644 --- a/src/text2.C +++ b/src/text2.C @@ -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); -- 2.39.2