]> git.lyx.org Git - lyx.git/blobdiff - src/TextMetrics.cpp
Forgot this one.
[lyx.git] / src / TextMetrics.cpp
index 1f0c62b725b86230d9cc88622e6f4042d1e6195b..f94accae67176f898c3fcce7f63ab485638f5909 100644 (file)
@@ -39,7 +39,7 @@
 
 #include "insets/InsetText.h"
 
-#include "mathed/MathMacroTemplate.h"
+#include "mathed/InsetMathMacroTemplate.h"
 
 #include "frontends/FontMetrics.h"
 #include "frontends/Painter.h"
@@ -97,7 +97,7 @@ int numberOfHfills(Row const & row, ParagraphMetrics const & pm,
 }
 
 
-}
+} // namespace
 
 /////////////////////////////////////////////////////////////////////
 //
@@ -433,7 +433,7 @@ bool TextMetrics::redoParagraph(pit_type const pit)
 
                // do the metric calculation
                Dimension dim;
-               int const w = max_width_ - leftMargin(max_width_, pit, ii->pos)
+               int const w = max_width_ - leftMargin(pit, ii->pos)
                        - right_margin - eop;
                Font const & font = ii->inset->inheritFont() ?
                        displayFont(pit, ii->pos) : bufferfont;
@@ -747,7 +747,7 @@ int TextMetrics::labelEnd(pit_type const pit) const
        if (text_->getPar(pit).layout().margintype != MARGIN_MANUAL)
                return 0;
        // return the beginning of the body
-       return leftMargin(max_width_, pit);
+       return leftMargin(pit);
 }
 
 namespace {
@@ -806,7 +806,7 @@ private:
        pos_type bodypos_;
 };
 
-} // anon namespace
+} // namespace
 
 /** This is the function where the hard work is done. The code here is
  * very sensitive to small changes :) Note that part of the
@@ -822,7 +822,7 @@ bool TextMetrics::breakRow(Row & row, int const right_margin) const
        bool need_new_row = false;
 
        row.clear();
-       row.left_margin = leftMargin(max_width_, row.pit(), pos);
+       row.left_margin = leftMargin(row.pit(), pos);
        row.right_margin = right_margin;
        if (is_rtl)
                swap(row.left_margin, row.right_margin);
@@ -963,7 +963,7 @@ bool TextMetrics::breakRow(Row & row, int const right_margin) const
 
        // if the row is too large, try to cut at last separator. In case
        // of success, reset indication that the row was broken abruptly.
-       int const next_width = max_width_ - leftMargin(max_width_, row.pit(), row.endpos())
+       int const next_width = max_width_ - leftMargin(row.pit(), row.endpos())
                - rightMargin(row.pit());
 
        row.shortenIfNeeded(body_pos, width, next_width);
@@ -1379,7 +1379,9 @@ Inset * TextMetrics::editXY(Cursor & cur, int x, int y,
 
        // Try to descend recursively inside the inset.
        Inset * edited = inset->editXY(cur, x, y);
-       if (edited == inset && cur.pos() == it->pos) {
+       // FIXME: it is not clear that the test on position is needed
+       // Remove it if/when semantics of editXY is clarified
+       if (cur.text() == text_ && cur.pos() == it->pos) {
                // non-editable inset, set cursor after the inset if x is
                // nearer to that position (bug 9628)
                bool bound = false; // is modified by getPosNearX
@@ -1580,14 +1582,13 @@ bool TextMetrics::isFirstRow(Row const & row) const
 }
 
 
-int TextMetrics::leftMargin(int max_width, pit_type pit) const
+int TextMetrics::leftMargin(pit_type pit) const
 {
-       return leftMargin(max_width, pit, text_->paragraphs()[pit].size());
+       return leftMargin(pit, text_->paragraphs()[pit].size());
 }
 
 
-int TextMetrics::leftMargin(int max_width,
-               pit_type const pit, pos_type const pos) const
+int TextMetrics::leftMargin(pit_type const pit, pos_type const pos) const
 {
        ParagraphList const & pars = text_->paragraphs();
 
@@ -1620,7 +1621,7 @@ int TextMetrics::leftMargin(int max_width,
                                int nestmargin = depth * nestMargin();
                                if (text_->isMainText())
                                        nestmargin += changebarMargin();
-                               l_margin = max(leftMargin(max_width, newpar), nestmargin);
+                               l_margin = max(leftMargin(newpar), nestmargin);
                                // Remove the parindent that has been added
                                // if the paragraph was empty.
                                if (pars[newpar].empty() &&
@@ -1719,7 +1720,7 @@ int TextMetrics::leftMargin(int max_width,
                ParagraphMetrics const & pm = par_metrics_[pit];
                RowList::const_iterator rit = pm.rows().begin();
                RowList::const_iterator end = pm.rows().end();
-               int minfill = max_width;
+               int minfill = max_width_;
                for ( ; rit != end; ++rit)
                        if (rit->fill() < minfill)
                                minfill = rit->fill();
@@ -1727,13 +1728,13 @@ int TextMetrics::leftMargin(int max_width,
                l_margin += minfill;
 #endif
                // also wrong, but much shorter.
-               l_margin += max_width / 2;
+               l_margin += max_width_ / 2;
                break;
        }
        }
 
        if (!par.params().leftIndent().zero())
-               l_margin += par.params().leftIndent().inPixels(max_width, lfm.em());
+               l_margin += par.params().leftIndent().inPixels(max_width_, lfm.em());
 
        LyXAlignment align = par.getAlign();