]> git.lyx.org Git - lyx.git/blobdiff - src/rowpainter.cpp
* do not ignore "requires" field in MathMacro
[lyx.git] / src / rowpainter.cpp
index 74bc9242d033f460861590439020646d3c822614..afb99897ef0b64bd72462bf0c282eccba01ea035 100644 (file)
 
 #include "Buffer.h"
 #include "CoordCache.h"
-#include "LCursor.h"
+#include "Cursor.h"
 #include "debug.h"
 #include "BufferParams.h"
 #include "BufferView.h"
 #include "Encoding.h"
 #include "gettext.h"
 #include "Language.h"
-#include "LColor.h"
+#include "Color.h"
 #include "LyXRC.h"
 #include "Row.h"
 #include "MetricsInfo.h"
@@ -65,7 +65,7 @@ bool refreshInside;
 class RowPainter {
 public:
        /// initialise and run painter
-       RowPainter(PainterInfo & pi, LyXText const & text,
+       RowPainter(PainterInfo & pi, Text const & text,
                pit_type pit, Row const & row, int x, int y);
 
        // paint various parts
@@ -78,20 +78,20 @@ public:
        int maxWidth() { return max_width_; }
 
 private:
-       void paintForeignMark(double orig_x, LyXFont const & font, int desc = 0);
-       void paintHebrewComposeChar(pos_type & vpos, LyXFont const & font);
-       void paintArabicComposeChar(pos_type & vpos, LyXFont const & font);
-       void paintChars(pos_type & vpos, LyXFont const & font,
+       void paintForeignMark(double orig_x, Font const & font, int desc = 0);
+       void paintHebrewComposeChar(pos_type & vpos, Font const & font);
+       void paintArabicComposeChar(pos_type & vpos, Font const & font);
+       void paintChars(pos_type & vpos, Font const & font,
                        bool hebrew, bool arabic);
        int paintAppendixStart(int y);
        void paintFromPos(pos_type & vpos);
-       void paintInset(pos_type const pos, LyXFont const & font);
+       void paintInset(pos_type const pos, Font const & font);
 
        /// return left margin
        int leftMargin() const;
 
        /// return the label font for this row
-       LyXFont const getLabelFont() const;
+       Font const getLabelFont() const;
 
        /// bufferview to paint on
        BufferView & bv_;
@@ -99,8 +99,8 @@ private:
        /// Painter to use
        Painter & pain_;
 
-       /// LyXText for the row
-       LyXText const & text_;
+       /// Text for the row
+       Text const & text_;
        TextMetrics & text_metrics_;
        ParagraphList const & pars_;
 
@@ -128,7 +128,7 @@ private:
 
 
 RowPainter::RowPainter(PainterInfo & pi,
-       LyXText const & text, pit_type pit, Row const & row, int x, int y)
+       Text const & text, pit_type pit, Row const & row, int x, int y)
        : bv_(*pi.base.bv), pain_(pi.pain), text_(text),
          text_metrics_(pi.base.bv->textMetrics(&text)),
          pars_(text.paragraphs()),
@@ -153,7 +153,7 @@ RowPainter::RowPainter(PainterInfo & pi,
 }
 
 
-LyXFont const RowPainter::getLabelFont() const
+Font const RowPainter::getLabelFont() const
 {
        return text_.getLabelFont(*bv_.buffer(), par_);
 }
@@ -170,13 +170,13 @@ int RowPainter::leftMargin() const
 // This draws green lines around each inset.
 
 
-void RowPainter::paintInset(pos_type const pos, LyXFont const & font)
+void RowPainter::paintInset(pos_type const pos, Font const & font)
 {
-       InsetBase const * inset = par_.getInset(pos);
+       Inset const * inset = par_.getInset(pos);
        BOOST_ASSERT(inset);
        PainterInfo pi(const_cast<BufferView *>(&bv_), pain_);
        // FIXME: We should always use font, see documentation of
-       // noFontChange() in InsetBase.h.
+       // noFontChange() in Inset.h.
        pi.base.font = inset->noFontChange() ?
                bv_.buffer()->params().getFont() :
                font;
@@ -223,15 +223,15 @@ void RowPainter::paintInset(pos_type const pos, LyXFont const & font)
        int const x2 = x1 + dim.wid;
        int const y1 = yo_ + dim.des;
        int const y2 = yo_ - dim.asc;
-       pi.pain.line(x1, y1, x1, y2, LColor::green);
-       pi.pain.line(x1, y1, x2, y1, LColor::green);
-       pi.pain.line(x2, y1, x2, y2, LColor::green);
-       pi.pain.line(x1, y2, x2, y2, LColor::green);
+       pi.pain.line(x1, y1, x1, y2, Color::green);
+       pi.pain.line(x1, y1, x2, y1, Color::green);
+       pi.pain.line(x2, y1, x2, y2, Color::green);
+       pi.pain.line(x1, y2, x2, y2, Color::green);
 #endif
 }
 
 
-void RowPainter::paintHebrewComposeChar(pos_type & vpos, LyXFont const & font)
+void RowPainter::paintHebrewComposeChar(pos_type & vpos, Font const & font)
 {
        pos_type pos = text_.bidi.vis2log(vpos);
 
@@ -265,7 +265,7 @@ void RowPainter::paintHebrewComposeChar(pos_type & vpos, LyXFont const & font)
 }
 
 
-void RowPainter::paintArabicComposeChar(pos_type & vpos, LyXFont const & font)
+void RowPainter::paintArabicComposeChar(pos_type & vpos, Font const & font)
 {
        pos_type pos = text_.bidi.vis2log(vpos);
        docstring str;
@@ -295,7 +295,7 @@ void RowPainter::paintArabicComposeChar(pos_type & vpos, LyXFont const & font)
 }
 
 
-void RowPainter::paintChars(pos_type & vpos, LyXFont const & font,
+void RowPainter::paintChars(pos_type & vpos, Font const & font,
                            bool hebrew, bool arabic)
 {
        // This method takes up 70% of time when typing
@@ -366,11 +366,11 @@ void RowPainter::paintChars(pos_type & vpos, LyXFont const & font,
        docstring s(&str[0], str.size());
 
        if (prev_change != Change::UNCHANGED) {
-               LyXFont copy(font);
+               Font copy(font);
                if (prev_change == Change::DELETED) {
-                       copy.setColor(LColor::strikeout);
+                       copy.setColor(Color::strikeout);
                } else if (prev_change == Change::INSERTED) {
-                       copy.setColor(LColor::newtext);
+                       copy.setColor(Color::newtext);
                }
                x_ += pain_.text(int(x_), yo_, s, copy);
        } else {
@@ -379,7 +379,7 @@ void RowPainter::paintChars(pos_type & vpos, LyXFont const & font,
 }
 
 
-void RowPainter::paintForeignMark(double orig_x, LyXFont const & font, int desc)
+void RowPainter::paintForeignMark(double orig_x, Font const & font, int desc)
 {
        if (!lyxrc.mark_foreign_language)
                return;
@@ -389,14 +389,14 @@ void RowPainter::paintForeignMark(double orig_x, LyXFont const & font, int desc)
                return;
 
        int const y = yo_ + 1 + desc;
-       pain_.line(int(orig_x), y, int(x_), y, LColor::language);
+       pain_.line(int(orig_x), y, int(x_), y, Color::language);
 }
 
 
 void RowPainter::paintFromPos(pos_type & vpos)
 {
        pos_type const pos = text_.bidi.vis2log(vpos);
-       LyXFont orig_font = text_.getFont(*bv_.buffer(), par_, pos);
+       Font orig_font = text_.getFont(*bv_.buffer(), par_, pos);
 
        double const orig_x = x_;
 
@@ -449,7 +449,7 @@ void RowPainter::paintChangeBar()
                ? row_.ascent()
                : row_.height();
 
-       pain_.fillRectangle(5, yo_ - row_.ascent(), 3, height, LColor::changebar);
+       pain_.fillRectangle(5, yo_ - row_.ascent(), 3, height, Color::changebar);
 }
 
 
@@ -463,8 +463,8 @@ void RowPainter::paintAppendix()
        if (par_.params().startOfAppendix())
                y += 2 * defaultRowHeight();
 
-       pain_.line(1, y, 1, yo_ + row_.height(), LColor::appendix);
-       pain_.line(width_ - 2, y, width_ - 2, yo_ + row_.height(), LColor::appendix);
+       pain_.line(1, y, 1, yo_ + row_.height(), Color::appendix);
+       pain_.line(width_ - 2, y, width_ - 2, yo_ + row_.height(), Color::appendix);
 }
 
 
@@ -501,20 +501,20 @@ void RowPainter::paintDepthBar()
                int const starty = yo_ - row_.ascent();
                int const h =  row_.height() - 1 - (i - next_depth - 1) * 3;
 
-               pain_.line(x, starty, x, starty + h, LColor::depthbar);
+               pain_.line(x, starty, x, starty + h, Color::depthbar);
 
                if (i > prev_depth)
-                       pain_.fillRectangle(x, starty, w, 2, LColor::depthbar);
+                       pain_.fillRectangle(x, starty, w, 2, Color::depthbar);
                if (i > next_depth)
-                       pain_.fillRectangle(x, starty + h, w, 2, LColor::depthbar);
+                       pain_.fillRectangle(x, starty + h, w, 2, Color::depthbar);
        }
 }
 
 
 int RowPainter::paintAppendixStart(int y)
 {
-       LyXFont pb_font;
-       pb_font.setColor(LColor::appendix);
+       Font pb_font;
+       pb_font.setColor(Color::appendix);
        pb_font.decSize();
 
        int w = 0;
@@ -527,10 +527,10 @@ int RowPainter::paintAppendixStart(int y)
        int const text_start = int(xo_ + (width_ - w) / 2);
        int const text_end = text_start + w;
 
-       pain_.rectText(text_start, y + d, label, pb_font, LColor::none, LColor::none);
+       pain_.rectText(text_start, y + d, label, pb_font, Color::none, Color::none);
 
-       pain_.line(int(xo_ + 1), y, text_start, y, LColor::appendix);
-       pain_.line(text_end, y, int(xo_ + width_ - 2), y, LColor::appendix);
+       pain_.line(int(xo_ + 1), y, text_start, y, Color::appendix);
+       pain_.line(text_end, y, int(xo_ + width_ - 2), y, Color::appendix);
 
        return 3 * defaultRowHeight();
 }
@@ -548,7 +548,7 @@ void RowPainter::paintFirst()
 
        Buffer const & buffer = *bv_.buffer();
 
-       LyXLayout_ptr const & layout = par_.layout();
+       Layout_ptr const & layout = par_.layout();
 
        if (buffer.params().paragraph_separation == BufferParams::PARSEP_SKIP) {
                if (pit_ != 0) {
@@ -556,7 +556,7 @@ void RowPainter::paintFirst()
                                && !par_.getDepth()) {
                                y_top += buffer.params().getDefSkip().inPixels(bv_);
                        } else {
-                               LyXLayout_ptr const & playout = pars_[pit_ - 1].layout();
+                               Layout_ptr const & playout = pars_[pit_ - 1].layout();
                                if (playout->latextype == LATEX_PARAGRAPH
                                        && !pars_[pit_ - 1].getDepth()) {
                                        // is it right to use defskip here, too? (AS)
@@ -576,7 +576,7 @@ void RowPainter::paintFirst()
                      || layout->latextype != LATEX_ENVIRONMENT
                      || is_seq)) {
 
-               LyXFont const font = getLabelFont();
+               Font const font = getLabelFont();
                FontMetrics const & fm = theFontMetrics(font);
 
                docstring const str = par_.getLabelstring();
@@ -626,7 +626,7 @@ void RowPainter::paintFirst()
                (layout->labeltype == LABEL_TOP_ENVIRONMENT ||
                layout->labeltype == LABEL_BIBLIO ||
                layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) {
-               LyXFont font = getLabelFont();
+               Font font = getLabelFont();
                if (!par_.getLabelstring().empty()) {
                        docstring const str = par_.getLabelstring();
                        double spacing_val = 1.0;
@@ -669,7 +669,7 @@ void RowPainter::paintLast()
        if (par_.isInserted(par_.size()) || par_.isDeleted(par_.size())) {
                FontMetrics const & fm = theFontMetrics(bv_.buffer()->params().getFont());
                int const length = fm.maxAscent() / 2;
-               LColor::color col = par_.isInserted(par_.size()) ? LColor::newtext : LColor::strikeout;
+               Color::color col = par_.isInserted(par_.size()) ? Color::newtext : Color::strikeout;
                
                pain_.line(int(x_) + 1, yo_ + 2, int(x_) + 1, yo_ + 2 - length, col,
                           Painter::line_solid, Painter::line_thick);
@@ -682,7 +682,7 @@ void RowPainter::paintLast()
        switch (endlabel) {
        case END_LABEL_BOX:
        case END_LABEL_FILLED_BOX: {
-               LyXFont const font = getLabelFont();
+               Font const font = getLabelFont();
                FontMetrics const & fm = theFontMetrics(font);
                int const size = int(0.75 * fm.maxAscent());
                int const y = yo_ - size;
@@ -692,14 +692,14 @@ void RowPainter::paintLast()
                        x += (size - width_ + row_.width() + 1) * (is_rtl ? -1 : 1);
 
                if (endlabel == END_LABEL_BOX)
-                       pain_.rectangle(x, y, size, size, LColor::eolmarker);
+                       pain_.rectangle(x, y, size, size, Color::eolmarker);
                else
-                       pain_.fillRectangle(x, y, size, size, LColor::eolmarker);
+                       pain_.fillRectangle(x, y, size, size, Color::eolmarker);
                break;
        }
 
        case END_LABEL_STATIC: {
-               LyXFont font = getLabelFont();
+               Font font = getLabelFont();
                FontMetrics const & fm = theFontMetrics(font);
                docstring const & str = par_.layout()->endlabelstring();
                double const x = is_rtl ?
@@ -724,7 +724,7 @@ void RowPainter::paintText()
                body_pos = 0;
        }
 
-       LyXLayout_ptr const & layout = par_.layout();
+       Layout_ptr const & layout = par_.layout();
 
        bool running_strikeout = false;
        bool is_struckout = false;
@@ -732,7 +732,7 @@ void RowPainter::paintText()
 
        // Use font span to speed things up, see below
        FontSpan font_span;
-       LyXFont font;
+       Font font;
        Buffer const & buffer = *bv_.buffer();
 
        for (pos_type vpos = row_.pos(); vpos < end; ) {
@@ -779,7 +779,7 @@ void RowPainter::paintText()
                                = theFontMetrics(bv_.buffer()->params().getFont());
                        int const middle = yo_ - fm.maxAscent() / 3;
                        pain_.line(last_strikeout_x, middle, int(x_), middle,
-                               LColor::strikeout, Painter::line_solid, Painter::line_thin);
+                               Color::strikeout, Painter::line_solid, Painter::line_thin);
                        running_strikeout = false;
                }
 
@@ -797,23 +797,23 @@ void RowPainter::paintText()
                        int const y0 = yo_;
                        int const y1 = y0 - defaultRowHeight() / 2;
 
-                       pain_.line(int(x_), y1, int(x_), y0, LColor::added_space);
+                       pain_.line(int(x_), y1, int(x_), y0, Color::added_space);
 
                        if (par_.hfillExpansion(row_, pos)) {
                                int const y2 = (y0 + y1) / 2;
 
                                if (pos >= body_pos) {
                                        pain_.line(int(x_), y2, int(x_ + hfill_), y2,
-                                                 LColor::added_space,
+                                                 Color::added_space,
                                                  Painter::line_onoffdash);
                                        x_ += hfill_;
                                } else {
                                        pain_.line(int(x_), y2, int(x_ + label_hfill_), y2,
-                                                 LColor::added_space,
+                                                 Color::added_space,
                                                  Painter::line_onoffdash);
                                        x_ += label_hfill_;
                                }
-                               pain_.line(int(x_), y1, int(x_), y0, LColor::added_space);
+                               pain_.line(int(x_), y1, int(x_), y0, Color::added_space);
                        }
                        x_ += 2;
                        ++vpos;
@@ -834,17 +834,17 @@ void RowPainter::paintText()
                        = theFontMetrics(bv_.buffer()->params().getFont());
                int const middle = yo_ - fm.maxAscent() / 3;
                pain_.line(last_strikeout_x, middle, int(x_), middle,
-                       LColor::strikeout, Painter::line_solid, Painter::line_thin);
+                       Color::strikeout, Painter::line_solid, Painter::line_thin);
                running_strikeout = false;
        }
 }
 
 
 bool CursorOnRow(PainterInfo & pi, pit_type const pit,
-       RowList::const_iterator rit, LyXText const & text)
+       RowList::const_iterator rit, Text const & text)
 {
        // Is there a cursor on this row (or inside inset on row)
-       LCursor & cur = pi.base.bv->cursor();
+       Cursor & cur = pi.base.bv->cursor();
        for (size_type d = 0; d < cur.depth(); ++d) {
                CursorSlice const & sl = cur[d];
                if (sl.text() == &text
@@ -858,11 +858,11 @@ bool CursorOnRow(PainterInfo & pi, pit_type const pit,
 
 
 bool innerCursorOnRow(PainterInfo & pi, pit_type pit,
-       RowList::const_iterator rit, LyXText const & text)
+       RowList::const_iterator rit, Text const & text)
 {
        // Is there a cursor inside an inset on this row, and is this inset
        // the only "character" on this row
-       LCursor & cur = pi.base.bv->cursor();
+       Cursor & cur = pi.base.bv->cursor();
        if (rit->pos() + 1 != rit->endpos())
                return false;
        for (size_type d = 0; d < cur.depth(); d++) {
@@ -880,9 +880,9 @@ bool innerCursorOnRow(PainterInfo & pi, pit_type pit,
 bool inNarrowInset(PainterInfo & pi)
 {
        // check whether the current inset is nested in a non-wide inset
-       LCursor & cur = pi.base.bv->cursor();
+       Cursor & cur = pi.base.bv->cursor();
        for (int i = cur.depth() - 1; --i >= 0; ) {
-               InsetBase * const in = &cur[i].inset();
+               Inset * const in = &cur[i].inset();
                if (in) {
                        InsetText * t = 
                                const_cast<InsetText *>(in->asTextInset());
@@ -895,7 +895,7 @@ bool inNarrowInset(PainterInfo & pi)
 
 
 void paintPar
-       (PainterInfo & pi, LyXText const & text, pit_type pit, int x, int y,
+       (PainterInfo & pi, Text const & text, pit_type pit, int x, int y,
         bool repaintAll)
 {
 //     lyxerr << "  paintPar: pit: " << pit << " at y: " << y << endl;
@@ -939,7 +939,7 @@ void paintPar
                // JSpitzm: We should aim at removing wide() altogether while retaining
                // typing speed within insets.
                for (pos_type i = rit->pos() ; i != rit->endpos(); ++i) {
-                       InsetBase const * const in = par.getInset(i);
+                       Inset const * const in = par.getInset(i);
                        if (in) {
                                InsetText * t = const_cast<InsetText *>(in->asTextInset());
                                if (t)
@@ -1009,7 +1009,7 @@ void paintText(BufferView & bv,
 {
        BOOST_ASSERT(bv.buffer());
        Buffer const & buffer = *bv.buffer();
-       LyXText & text = buffer.text();
+       Text & text = buffer.text();
        bool const select = bv.cursor().selection();
        ViewMetricsInfo const & vi = bv.viewMetricsInfo();
        
@@ -1042,16 +1042,16 @@ void paintText(BufferView & bv,
        // and grey out above (should not happen later)
 //     lyxerr << "par ascent: " << text.getPar(vi.p1).ascent() << endl;
        if (vi.y1 > 0 && vi.update_strategy != SingleParUpdate)
-               pain.fillRectangle(0, 0, bv.workWidth(), vi.y1, LColor::bottomarea);
+               pain.fillRectangle(0, 0, bv.workWidth(), vi.y1, Color::bottomarea);
 
        // and possibly grey out below
 //     lyxerr << "par descent: " << text.getPar(vi.p1).ascent() << endl;
        if (vi.y2 < bv.workHeight() && vi.update_strategy != SingleParUpdate)
-               pain.fillRectangle(0, vi.y2, bv.workWidth(), bv.workHeight() - vi.y2, LColor::bottomarea);
+               pain.fillRectangle(0, vi.y2, bv.workWidth(), bv.workHeight() - vi.y2, Color::bottomarea);
 }
 
 
-void paintTextInset(LyXText const & text, PainterInfo & pi, int x, int y)
+void paintTextInset(Text const & text, PainterInfo & pi, int x, int y)
 {
 //     lyxerr << "  paintTextInset: y: " << y << endl;