]> git.lyx.org Git - features.git/commitdiff
some renaming
authorAlfredo Braunstein <abraunst@lyx.org>
Mon, 1 Mar 2004 16:29:30 +0000 (16:29 +0000)
committerAlfredo Braunstein <abraunst@lyx.org>
Mon, 1 Mar 2004 16:29:30 +0000 (16:29 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8471 a592a061-630c-0410-9148-cb99ea01b6c8

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

index 4d7de765db712f2096372ed4eddc94cbbd93c4d4..755a325c817626b3de0e216d605f76df38a94667 100644 (file)
@@ -319,8 +319,6 @@ void BufferView::Pimpl::buffer(Buffer * b)
                connectBuffer(*buffer_);
 
                buffer_->text().init(bv_);
-               buffer_->text().textwidth_ = workarea().workWidth();
-               buffer_->text().fullRebreak();
 
                // If we don't have a text object for this, we make one
                if (bv_->text() == 0)
@@ -404,8 +402,7 @@ void BufferView::Pimpl::resizeCurrentBuffer()
        selendpos = cur.selEnd().pos();
        sel = cur.selection();
        mark_set = cur.mark();
-       text->textwidth_ = bv_->workWidth();
-       text->fullRebreak();
+       text->init(bv_);
        update();
 
        if (par != -1) {
@@ -448,10 +445,11 @@ void BufferView::Pimpl::updateScrollbar()
 
        LyXText const & t = *bv_->text();
 
-       lyxerr[Debug::GUI] << "Updating scrollbar: h " << t.height << ", top_y() "
-               << top_y() << ", default height " << defaultRowHeight() << endl;
+       lyxerr[Debug::GUI] << "Updating scrollbar: h" << t.height()
+                          << ", top_y()" << top_y() << ", default height "
+                          << defaultRowHeight() << endl;
 
-       workarea().setScrollbarParams(t.height, top_y(), defaultRowHeight());
+       workarea().setScrollbarParams(t.height(), top_y(), defaultRowHeight());
 }
 
 
@@ -499,13 +497,13 @@ void BufferView::Pimpl::scroll(int lines)
        int new_top_y = top_y() + lines * line_height;
 
        // Restrict to a valid value
-       new_top_y = std::min(t->height - 4 * line_height, new_top_y);
+       new_top_y = std::min(t->height() - 4 * line_height, new_top_y);
        new_top_y = std::max(0, new_top_y);
 
        scrollDocView(new_top_y);
 
        // Update the scrollbar.
-       workarea().setScrollbarParams(t->height, top_y(), defaultRowHeight());
+       workarea().setScrollbarParams(t->height(), top_y(), defaultRowHeight());
 }
 
 
index 3ea318b02c1d8f43eb1617c95460c8cc070f6332..5a814307cbb1a41f64769436386a03b8a389ee55 100644 (file)
@@ -1,3 +1,11 @@
+2004-03-01  Alfredo Braunstein  <abraunst@lyx.org>
+
+       * lyxtext.h:
+       * text.C:
+       * text2.C:
+       * rowpainter.C:
+       * BufferView_pimpl.C: rename textwidth -> maxwidth, 
+       prepareToPrint -> computeRowMetrics and remove textWidth accessor.
 
 2004-03-01  Alfredo Braunstein  <abraunst@lyx.org>
 
index 865c78865b2bf9b128494c5f8ae8239274e2be6a..d2c393df4d01902acbf64dc568093977847524fa 100644 (file)
@@ -290,9 +290,12 @@ public:
        ///
        void gotoInset(LCursor & cur, InsetOld_code code, bool same_content);
 
-       /// current max text width
-       int textWidth() const;
+       /// current text width
+       int width() const;
 
+       /// current text heigth
+       int height() const;
+       
        /// updates all counters
        void updateCounters();
        /// Returns an inset if inset was hit, or 0 if not.
@@ -321,7 +324,7 @@ public:
        /** this calculates the specified parameters. needed when setting
         * the cursor and when creating a visible row */
        RowMetrics
-       prepareToPrint(ParagraphList::iterator pit, Row const & row) const;
+       computeRowMetrics(ParagraphList::iterator pit, Row const & row) const;
 
        /// access to our paragraphs
        ParagraphList & paragraphs() const;
@@ -376,13 +379,13 @@ public:
 
        friend class LyXScreen;
 
-public:
        ///
-       int height;
+       unsigned int width_;
        ///
-       unsigned int width;
+       int maxwidth_;
        ///
-       int textwidth_;
+       int height_;
+public:
        /// the current font settings
        LyXFont current_font;
        /// the current font
index 03a48bdd6d0b5ab195b4aff4ebd6dabbb135e04c..117f82bed152b9df0fb7bba2f44084ec9db4b8e0 100644 (file)
@@ -120,12 +120,12 @@ RowPainter::RowPainter(BufferView const & bv, LyXText const & text,
      ParagraphList::iterator pit, RowList::iterator rit,
      int xo, int yo)
        : bv_(bv), pain_(bv_.painter()), text_(text), rit_(rit), row_(*rit),
-         pit_(pit), xo_(xo), yo_(yo), width_(text_.width)
+         pit_(pit), xo_(xo), yo_(yo), width_(text_.width())
 {
        //lyxerr << "RowPainter: x: " << x_ << " xo: " << xo << " yo: " << yo
        //      << " pit->y: " << pit_->y
        //      << " row: " << (pit_->size() ? pit_->getChar(row_.pos()) : 'X') << endl;
-       RowMetrics m = text_.prepareToPrint(pit, row_);
+       RowMetrics m = text_.computeRowMetrics(pit, row_);
        x_ = m.x + xo_;
        separator_ = m.separator;
        hfill_ = m.hfill;
index 055ebc93642f601ceafc9e64b77b8995b20b7889..e8754421c103a9f58b58b516f333f40106783df9 100644 (file)
@@ -177,16 +177,22 @@ void LyXText::updateParPositions()
 {
        ParagraphList::iterator pit = paragraphs().begin();
        ParagraphList::iterator end = paragraphs().end();
-       for (height = 0; pit != end; ++pit) {
-               pit->y = height;
-               height += pit->height;
+       for (height_ = 0; pit != end; ++pit) {
+               pit->y = height_;
+               height_ += pit->height;
        }
 }
 
 
-int LyXText::textWidth() const
+int LyXText::width() const
 {
-       return textwidth_;
+       return width_;
+}
+
+
+int LyXText::height() const
+{
+       return height_;
 }
 
 
@@ -355,7 +361,7 @@ int LyXText::leftMargin(ParagraphList::iterator pit, pos_type pos) const
                RowList::iterator rit = pit->rows.begin();
                RowList::iterator end = pit->rows.end();
 #warning This is wrong.
-               int minfill = textwidth_;
+               int minfill = maxwidth_;
                for ( ; rit != end; ++rit)
                        if (rit->fill() < minfill)
                                minfill = rit->fill();
@@ -364,14 +370,14 @@ int LyXText::leftMargin(ParagraphList::iterator pit, pos_type pos) const
                x += minfill;
 #endif
                // also wrong, but much shorter.
-               x += textwidth_ / 2;
+               x += maxwidth_ / 2;
                break;
        }
        }
        
 
        if (!pit->params().leftIndent().zero())
-               x += pit->params().leftIndent().inPixels(textWidth());
+               x += pit->params().leftIndent().inPixels(maxwidth_);
 
        LyXAlignment align;
 
@@ -457,7 +463,7 @@ void LyXText::rowBreakPoint(ParagraphList::iterator pit, Row & row) const
        }
 
        // maximum pixel width of a row
-       int width = textWidth() - rightMargin(*pit); // - leftMargin(pit, row);
+       int width = maxwidth_ - rightMargin(*pit); // - leftMargin(pit, row);
        if (width < 0) {
                row.endpos(end);
                return;
@@ -1007,11 +1013,11 @@ void LyXText::charInserted()
 
 
 RowMetrics
-LyXText::prepareToPrint(ParagraphList::iterator pit, Row const & row) const
+LyXText::computeRowMetrics(ParagraphList::iterator pit, Row const & row) const
 {
        RowMetrics result;
 
-       double w = width - row.width();
+       double w = width_ - row.width();
 
        bool const is_rtl = isRTL(*pit);
        if (is_rtl)
@@ -1048,7 +1054,7 @@ LyXText::prepareToPrint(ParagraphList::iterator pit, Row const & row) const
        // we don't have to look at the alignment if it is ALIGN_LEFT and
        // if the row is already larger then the permitted width as then
        // we force the LEFT_ALIGN'edness!
-       } else if (int(row.width()) < textWidth()) {
+       } else if (int(row.width()) < maxwidth_) {
                // is it block, flushleft or flushright?
                // set x how you need it
                int align;
@@ -1551,7 +1557,7 @@ int LyXText::parOffset(ParagraphList::iterator pit) const
 void LyXText::redoParagraphInternal(ParagraphList::iterator pit)
 {
        // remove rows of paragraph, keep track of height changes
-       height -= pit->height;
+       height_ -= pit->height;
 
        // clear old data
        pit->rows.clear();
@@ -1563,7 +1569,7 @@ void LyXText::redoParagraphInternal(ParagraphList::iterator pit)
        InsetList::iterator iend = pit->insetlist.end();
        for (; ii != iend; ++ii) {
                Dimension dim;
-               int const w = textWidth() - leftMargin(pit) - rightMargin(*pit);
+               int const w = maxwidth_ - leftMargin(pit) - rightMargin(*pit);
                MetricsInfo mi(bv(), getFont(pit, ii->pos), w);
                ii->inset->metrics(mi, dim);
        }
@@ -1583,7 +1589,7 @@ void LyXText::redoParagraphInternal(ParagraphList::iterator pit)
                z = row.endpos();
        } while (z < pit->size());
 
-       height += pit->height;
+       height_ += pit->height;
        //lyxerr << "redoParagraph: " << pit->rows.size() << " rows\n";
 }
 
@@ -1615,19 +1621,20 @@ void LyXText::metrics(MetricsInfo & mi, Dimension & dim)
 {
        //BOOST_ASSERT(mi.base.textwidth);
        if (mi.base.textwidth)
-               textwidth_ = mi.base.textwidth;
+               maxwidth_ = mi.base.textwidth;
        //lyxerr << "LyXText::metrics: width: " << mi.base.textwidth
-       //      << " textWidth: " << textWidth() << "\nfont: " << mi.base.font << endl;
+       //<< " maxWidth: " << maxwidth << "\nfont: " << mi.base.font
+       //<< endl;
 
        // Rebuild row cache. This recomputes height as well.
        redoParagraphs(paragraphs().begin(), paragraphs().end());
 
-       width = maxParagraphWidth(paragraphs());
+       width_ = maxParagraphWidth(paragraphs());
 
        // final dimension
        dim.asc = firstRow()->ascent_of_text();
-       dim.des = height - dim.asc;
-       dim.wid = width;
+       dim.des = height_ - dim.asc;
+       dim.wid = width_;
 }
 
 
@@ -1804,7 +1811,7 @@ int LyXText::ascent() const
 
 int LyXText::descent() const
 {
-       return height - firstRow()->ascent_of_text();
+       return height_ - firstRow()->ascent_of_text();
 }
 
 
@@ -1819,7 +1826,7 @@ int LyXText::cursorX(CursorSlice const & cur) const
        pos_type pos = cur.pos();
        pos_type cursor_vpos = 0;
 
-       RowMetrics const m = prepareToPrint(pit, row);
+       RowMetrics const m = computeRowMetrics(pit, row);
        double x = m.x;
 
        pos_type const row_pos  = row.pos();
@@ -2040,8 +2047,8 @@ int LyXText::dist(int x, int y) const
 
        if (x < xo_)
                xx = xo_ - x;
-       else if (x > xo_ + width)
-               xx = x - xo_ - width;
+       else if (x > xo_ + width_)
+               xx = x - xo_ - width_;
 
        if (y < yo_ - ascent())
                yy = yo_ - ascent() - y;
index aed16a2e63d50d1af88905b99506c2a07251e87b..af078d47b412e20feb35d4d30aac4f6797182bcd 100644 (file)
@@ -72,8 +72,8 @@ using std::string;
 
 
 LyXText::LyXText(BufferView * bv, bool in_inset)
-       : height(0), width(0), textwidth_(bv ? bv->workWidth() : 100),
-               background_color_(LColor::background),
+       : height_(0), width_(0), maxwidth_(bv ? bv->workWidth() : 100),
+         background_color_(LColor::background),
          bv_owner(bv), in_inset_(in_inset), xo_(0), yo_(0)
 {}
 
@@ -87,8 +87,9 @@ void LyXText::init(BufferView * bv)
        for (ParagraphList::iterator pit = beg; pit != end; ++pit)
                pit->rows.clear();
 
-       width = bv->workWidth();
-       height = 0;
+       maxwidth_ = bv->workWidth();
+       width_ = maxwidth_;
+       height_ = 0;
 
        current_font = getFont(beg, 0);
 
@@ -1197,7 +1198,7 @@ pos_type LyXText::getColumnNearX(ParagraphList::iterator pit,
        Row const & row, int & x, bool & boundary) const
 {
        x -= xo_;
-       RowMetrics const r = prepareToPrint(pit, row);
+       RowMetrics const r = computeRowMetrics(pit, row);
        
        pos_type vc = row.pos();
        pos_type end = row.endpos();