X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetSpace.cpp;h=bdc7d51d5eb9e5f595531ef8cabe33d0f335a46d;hb=2c357c1d23b7b83839a9beb8225d4f1ae4f793b4;hp=bb57145452698bea8c0dfe4c059cddfd25aef3e9;hpb=237c132c1e6fc720b87f2fea6deb18a8395cbe0a;p=lyx.git diff --git a/src/insets/InsetSpace.cpp b/src/insets/InsetSpace.cpp index bb57145452..bdc7d51d5e 100644 --- a/src/insets/InsetSpace.cpp +++ b/src/insets/InsetSpace.cpp @@ -15,8 +15,7 @@ #include "InsetSpace.h" -#include "debug.h" -#include "Color.h" +#include "Dimension.h" #include "Lexer.h" #include "MetricsInfo.h" #include "OutputParams.h" @@ -24,12 +23,12 @@ #include "frontends/FontMetrics.h" #include "frontends/Painter.h" +#include "support/debug.h" +#include "support/docstream.h" -namespace lyx { +using namespace std; -using std::string; -using std::max; -using std::ostream; +namespace lyx { InsetSpace::InsetSpace() @@ -49,44 +48,46 @@ InsetSpace::Kind InsetSpace::kind() const void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const { - frontend::FontMetrics const & fm = - theFontMetrics(mi.base.font); + frontend::FontMetrics const & fm = theFontMetrics(mi.base.font); dim.asc = fm.maxAscent(); dim.des = fm.maxDescent(); switch (kind_) { case THIN: case NEGTHIN: - dim.wid = fm.width(char_type('x')) / 3; + dim.wid = fm.width(char_type('M')) / 6; break; case PROTECTED: case NORMAL: - dim.wid = fm.width(char_type('x')); + dim.wid = fm.width(char_type(' ')); break; case QUAD: - dim.wid = 20; + dim.wid = fm.width(char_type('M')); break; case QQUAD: - dim.wid = 40; + dim.wid = 2 * fm.width(char_type('M')); break; case ENSPACE: case ENSKIP: - dim.wid = 10; + dim.wid = int(0.5 * fm.width(char_type('M'))); break; } + // Cache the inset dimension. + setDimCache(mi, dim); } void InsetSpace::draw(PainterInfo & pi, int x, int y) const { - int const w = dim_.wid; + Dimension const dim = dimension(*pi.base.bv); + int const w = dim.wid; int const h = theFontMetrics(pi.base.font) .ascent('x'); int xp[4], yp[4]; xp[0] = x; yp[0] = y - max(h / 4, 1); - if (kind_ == NORMAL) { + if (kind_ == NORMAL || kind_ == PROTECTED) { xp[1] = x; yp[1] = y; xp[2] = x + w; yp[2] = y; } else { @@ -97,9 +98,9 @@ void InsetSpace::draw(PainterInfo & pi, int x, int y) const yp[3] = y - max(h / 4, 1); if (kind_ == PROTECTED || kind_ == ENSPACE || kind_ == NEGTHIN) - pi.pain.lines(xp, yp, 4, Color::latex); + pi.pain.lines(xp, yp, 4, Color_latex); else - pi.pain.lines(xp, yp, 4, Color::special); + pi.pain.lines(xp, yp, 4, Color_special); } @@ -224,10 +225,9 @@ int InsetSpace::docbook(Buffer const &, odocstream & os, } -int InsetSpace::textString(Buffer const & buf, odocstream & os, - OutputParams const & op) const +void InsetSpace::textString(Buffer const & buf, odocstream & os) const { - return plaintext(buf, os, op); + plaintext(buf, os, OutputParams(0)); }