]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetspace.C
Clean up InsetGraphics::Cache and rename as GraphicsInset.
[lyx.git] / src / insets / insetspace.C
index d4abadea67c4165cfe07aad961aab8d0040913a0..0ec7e9134718b038932e9a7e1493b4fd86b112ab 100644 (file)
 #include "debug.h"
 #include "dimension.h"
 #include "LaTeXFeatures.h"
+#include "latexrunparams.h"
 #include "BufferView.h"
 #include "frontends/Painter.h"
 #include "frontends/font_metrics.h"
 #include "lyxlex.h"
 #include "lyxfont.h"
+#include "metricsinfo.h"
 
 using std::ostream;
 using std::max;
 
 
+InsetSpace::InsetSpace()
+{}
+
+
 InsetSpace::InsetSpace(Kind k)
        : kind_(k)
 {}
@@ -39,60 +45,57 @@ InsetSpace::Kind InsetSpace::kind() const
 }
 
 
-void InsetSpace::dimension(BufferView *, LyXFont const & font,
-                          Dimension & dim) const
+void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const
 {
-       dim.a = font_metrics::maxAscent(font);
-       dim.d = font_metrics::maxDescent(font);
+       LyXFont & font = mi.base.font;
+       dim.asc = font_metrics::maxAscent(font);
+       dim.des = font_metrics::maxDescent(font);
 
        switch (kind_) {
                case THIN:
                case NEGTHIN:
-                       dim.w = font_metrics::width("x", font) / 3;
+                       dim.wid = font_metrics::width("x", font) / 3;
                        break;
                case PROTECTED:
                case NORMAL:
-                       dim.w = font_metrics::width("x", font);
+                       dim.wid = font_metrics::width("x", font);
                        break;
                case QUAD:
-                       dim.w = 20;
+                       dim.wid = 20;
                        break;
                case QQUAD:
-                       dim.w = 40;
+                       dim.wid = 40;
                        break;
                case ENSPACE:
                case ENSKIP:
-                       dim.w = 10;
+                       dim.wid = 10;
                        break;
        }
 }
 
 
-void InsetSpace::draw(BufferView * bv, LyXFont const & f,
-                           int baseline, float & x) const
+void InsetSpace::draw(PainterInfo & pi, int x, int y) const
 {
-       Painter & pain = bv->painter();
-       LyXFont font(f);
-
-       float w = width(bv, font);
-       int h = font_metrics::ascent('x', font);
+       int const w = width(pi.base.bv, pi.base.font);
+       int const h = font_metrics::ascent('x', pi.base.font);
        int xp[4], yp[4];
 
-       xp[0] = int(x); yp[0] = baseline - max(h / 4, 1);
+       xp[0] = x;
+       yp[0] = y - max(h / 4, 1);
        if (kind_ == NORMAL) {
-               xp[1] = int(x); yp[1] = baseline;
-               xp[2] = int(x + w); yp[2] = baseline;
+               xp[1] = x;     yp[1] = y;
+               xp[2] = x + w; yp[2] = y;
        } else {
-               xp[1] = int(x); yp[1] = baseline + max(h / 4, 1);
-               xp[2] = int(x + w); yp[2] = baseline + max(h / 4, 1);
+               xp[1] = x;     yp[1] = y + max(h / 4, 1);
+               xp[2] = x + w; yp[2] = y + max(h / 4, 1);
        }
-       xp[3] = int(x + w); yp[3] = baseline - max(h / 4, 1);
+       xp[3] = x + w;
+       yp[3] = y - max(h / 4, 1);
 
        if (kind_ == PROTECTED || kind_ == ENSPACE || kind_ == NEGTHIN)
-               pain.lines(xp, yp, 4, LColor::latex);
+               pi.pain.lines(xp, yp, 4, LColor::latex);
        else
-               pain.lines(xp, yp, 4, LColor::special);
-       x += w;
+               pi.pain.lines(xp, yp, 4, LColor::special);
 }
 
 
@@ -156,33 +159,33 @@ void InsetSpace::read(Buffer const *, LyXLex & lex)
 }
 
 
-int InsetSpace::latex(Buffer const *, ostream & os, bool /*fragile*/,
-                           bool free_space) const
+int InsetSpace::latex(Buffer const *, ostream & os,
+                     LatexRunParams const & runparams) const
 {
        switch (kind_) {
        case NORMAL:
-               os << (free_space ? " " : "\\ ");
+               os << (runparams.free_spacing ? " " : "\\ ");
                break;
        case PROTECTED:
-               os << (free_space ? ' ' : '~');
+               os << (runparams.free_spacing ? ' ' : '~');
                break;
        case THIN:
-               os << (free_space ? " " : "\\,");
+               os << (runparams.free_spacing ? " " : "\\,");
                break;
        case QUAD:
-               os << (free_space ? " " : "\\quad{}");
+               os << (runparams.free_spacing ? " " : "\\quad{}");
                break;
        case QQUAD:
-               os << (free_space ? " " : "\\qquad{}");
+               os << (runparams.free_spacing ? " " : "\\qquad{}");
                break;
        case ENSPACE:
-               os << (free_space ? " " : "\\enspace{}");
+               os << (runparams.free_spacing ? " " : "\\enspace{}");
                break;
        case ENSKIP:
-               os << (free_space ? " " : "\\enskip{}");
+               os << (runparams.free_spacing ? " " : "\\enskip{}");
                break;
        case NEGTHIN:
-               os << (free_space ? " " : "\\negthinspace{}");
+               os << (runparams.free_spacing ? " " : "\\negthinspace{}");
                break;
        }
        return 0;
@@ -249,7 +252,7 @@ int InsetSpace::docbook(Buffer const *, ostream & os, bool) const
 }
 
 
-Inset * InsetSpace::clone(Buffer const &, bool) const
+Inset * InsetSpace::clone() const
 {
        return new InsetSpace(kind_);
 }