]> git.lyx.org Git - lyx.git/blobdiff - src/TextMetrics.cpp
BufferParams.cpp: fix bug 3568:
[lyx.git] / src / TextMetrics.cpp
index 1ad906907cb837572e7d1b11c6ba17dacb2c1f80..d80c66167fe2907116dee21845de89ad41ee56c3 100644 (file)
@@ -31,7 +31,7 @@
 #include "Color.h"
 #include "Length.h"
 #include "LyXRC.h"
-#include "LyXText.h"
+#include "Text.h"
 #include "MetricsInfo.h"
 #include "ParagraphParameters.h"
 #include "VSpace.h"
@@ -106,7 +106,7 @@ int numberOfHfills(Paragraph const & par, Row const & row)
 
 } // namespace anon
 
-TextMetrics::TextMetrics(BufferView * bv, LyXText * text)
+TextMetrics::TextMetrics(BufferView * bv, Text * text)
        : bv_(bv), text_(text)
 {
        BOOST_ASSERT(bv_);
@@ -145,7 +145,7 @@ bool TextMetrics::metrics(MetricsInfo & mi, Dimension & dim)
        BOOST_ASSERT(mi.base.textwidth);
        max_width_ = mi.base.textwidth;
 
-       //lyxerr << "LyXText::metrics: width: " << mi.base.textwidth
+       //lyxerr << "Text::metrics: width: " << mi.base.textwidth
        //      << " maxWidth: " << max_width_ << "\nfont: " << mi.base.font << endl;
        
        bool changed = false;
@@ -201,15 +201,15 @@ bool TextMetrics::redoParagraph(pit_type const pit)
 
        // redo insets
        // FIXME: We should always use getFont(), see documentation of
-       // noFontChange() in InsetBase.h.
-       LyXFont const bufferfont = buffer.params().getFont();
+       // noFontChange() in Inset.h.
+       Font const bufferfont = buffer.params().getFont();
        InsetList::const_iterator ii = par.insetlist.begin();
        InsetList::const_iterator iend = par.insetlist.end();
        for (; ii != iend; ++ii) {
                Dimension dim;
                int const w = max_width_ - text_->leftMargin(buffer, max_width_, pit, ii->pos)
                        - right_margin;
-               LyXFont const & font = ii->inset->noFontChange() ?
+               Font const & font = ii->inset->noFontChange() ?
                        bufferfont : text_->getFont(buffer, par, ii->pos);
                MetricsInfo mi(bv_, font, w);
                changed |= ii->inset->metrics(mi, dim);
@@ -281,7 +281,7 @@ RowMetrics TextMetrics::computeRowMetrics(pit_type const pit,
                result.x = text_->leftMargin(buffer, max_width_, pit, row.pos());
 
        // is there a manual margin with a manual label
-       LyXLayout_ptr const & layout = par.layout();
+       Layout_ptr const & layout = par.layout();
 
        if (layout->margintype == MARGIN_MANUAL
            && layout->labeltype == LABEL_MANUAL) {
@@ -334,7 +334,7 @@ RowMetrics TextMetrics::computeRowMetrics(pit_type const pit,
                        int const ns = numberOfSeparators(par, row);
                        bool disp_inset = false;
                        if (row.endpos() < par.size()) {
-                               InsetBase const * in = par.getInset(row.endpos());
+                               Inset const * in = par.getInset(row.endpos());
                                if (in)
                                        disp_inset = in->display();
                        }
@@ -453,7 +453,7 @@ void TextMetrics::rowBreakPoint(int width, pit_type const pit,
                return;
        }
 
-       LyXLayout_ptr const & layout = par.layout();
+       Layout_ptr const & layout = par.layout();
 
        if (layout->margintype == MARGIN_RIGHT_ADDRESS_BOX) {
                row.endpos(addressBreakPoint(pos, par));
@@ -606,20 +606,20 @@ void TextMetrics::setHeightOfRow(pit_type const pit,
        // ok, let us initialize the maxasc and maxdesc value.
        // Only the fontsize count. The other properties
        // are taken from the layoutfont. Nicer on the screen :)
-       LyXLayout_ptr const & layout = par.layout();
+       Layout_ptr const & layout = par.layout();
 
        // as max get the first character of this row then it can
        // increase but not decrease the height. Just some point to
        // start with so we don't have to do the assignment below too
        // often.
        Buffer const & buffer = *bv_->buffer();
-       LyXFont font = text_->getFont(buffer, par, row.pos());
-       LyXFont::FONT_SIZE const tmpsize = font.size();
+       Font font = text_->getFont(buffer, par, row.pos());
+       Font::FONT_SIZE const tmpsize = font.size();
        font = text_->getLayoutFont(buffer, pit);
-       LyXFont::FONT_SIZE const size = font.size();
+       Font::FONT_SIZE const size = font.size();
        font.setSize(tmpsize);
 
-       LyXFont labelfont = text_->getLabelFont(buffer, par);
+       Font labelfont = text_->getLabelFont(buffer, par);
 
        FontMetrics const & labelfont_metrics = theFontMetrics(labelfont);
        FontMetrics const & fontmetrics = theFontMetrics(font);
@@ -647,7 +647,7 @@ void TextMetrics::setHeightOfRow(pit_type const pit,
        int labeladdon = 0;
        pos_type const pos_end = row.endpos();
 
-       LyXFont::FONT_SIZE maxsize =
+       Font::FONT_SIZE maxsize =
                par.highestFontInRange(row.pos(), pos_end, size);
        if (maxsize > font.size()) {
                font.setSize(maxsize);
@@ -665,9 +665,10 @@ void TextMetrics::setHeightOfRow(pit_type const pit,
        // is it a top line?
        if (row.pos() == 0) {
                BufferParams const & bufparams = buffer.params();
-               // some parksips VERY EASY IMPLEMENTATION
+               // some parskips VERY EASY IMPLEMENTATION
                if (bufparams.paragraph_separation
                    == BufferParams::PARSEP_SKIP
+                       && par.ownerCode() != Inset::ERT_CODE
                        && pit > 0
                        && ((layout->isParagraph() && par.getDepth() == 0)
                            || (pars[pit - 1].layout()->isParagraph()
@@ -765,7 +766,7 @@ void TextMetrics::setHeightOfRow(pit_type const pit,
 
        // FIXME: the correct way is to do the following is to move the 
        // following code in another method specially tailored for the 
-       // main LyXText. The following test is thus bogus.
+       // main Text. The following test is thus bogus.
        // Top and bottom margin of the document (only at top-level)
        if (main_text_) {
                if (pit == 0 && row.pos() == 0)
@@ -788,7 +789,7 @@ pos_type TextMetrics::getColumnNearX(pit_type const pit,
 {
        Buffer const & buffer = *bv_->buffer();
 
-       /// For the main LyXText, it is possible that this pit is not
+       /// For the main Text, it is possible that this pit is not
        /// yet in the CoordCache when moving cursor up.
        /// x Paragraph coordinate is always 0 for main text anyway.
        int const xo = main_text_? 0 : bv_->coordCache().get(text_, pit).x_;
@@ -799,7 +800,7 @@ pos_type TextMetrics::getColumnNearX(pit_type const pit,
        pos_type vc = row.pos();
        pos_type end = row.endpos();
        pos_type c = 0;
-       LyXLayout_ptr const & layout = par.layout();
+       Layout_ptr const & layout = par.layout();
 
        bool left_side = false;
 
@@ -934,7 +935,7 @@ pos_type TextMetrics::x2pos(pit_type pit, int row, int x) const
 }
 
 
-//int LyXText::pos2x(pit_type pit, pos_type pos) const
+//int Text::pos2x(pit_type pit, pos_type pos) const
 //{
 //     ParagraphMetrics const & pm = parMetrics(pit);
 //     Row const & r = pm.rows()[row];
@@ -945,7 +946,7 @@ pos_type TextMetrics::x2pos(pit_type pit, int row, int x) const
 
 int defaultRowHeight()
 {
-       return int(theFontMetrics(LyXFont(LyXFont::ALL_SANE)).maxHeight() *  1.2);
+       return int(theFontMetrics(Font(Font::ALL_SANE)).maxHeight() *  1.2);
 }
 
 } // namespace lyx